diff --git a/modules/rostests/winetests/crypt32/CMakeLists.txt b/modules/rostests/winetests/crypt32/CMakeLists.txt index 28c8b1f9fbc..bef9c8f6b4e 100644 --- a/modules/rostests/winetests/crypt32/CMakeLists.txt +++ b/modules/rostests/winetests/crypt32/CMakeLists.txt @@ -25,7 +25,13 @@ add_executable(crypt32_winetest ${SOURCE} ${PCH_SKIP_SOURCE}) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(crypt32_winetest PRIVATE -Wno-format) +endif() + set_module_type(crypt32_winetest win32cui) add_importlibs(crypt32_winetest crypt32 advapi32 user32 shlwapi shell32 msvcrt kernel32) add_pch(crypt32_winetest precomp.h "${PCH_SKIP_SOURCE}") add_rostests_file(TARGET crypt32_winetest) +target_compile_definitions(crypt32_winetest PRIVATE wcsicmp=_wcsicmp) diff --git a/modules/rostests/winetests/crypt32/base64.c b/modules/rostests/winetests/crypt32/base64.c index 4ff76272e35..2263b236fa8 100644 --- a/modules/rostests/winetests/crypt32/base64.c +++ b/modules/rostests/winetests/crypt32/base64.c @@ -23,7 +23,6 @@ #include #include -#include "wine/heap.h" #include "wine/test.h" #define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n" @@ -58,6 +57,8 @@ static const BYTE toEncode4[] = static const BYTE toEncode5[] = "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI"; +static const BYTE toEncode6[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + static const struct BinTests tests[] = { { toEncode1, sizeof(toEncode1), "AA==\r\n", }, { toEncode2, sizeof(toEncode2), "AQI=\r\n", }, @@ -70,6 +71,9 @@ static const struct BinTests tests[] = { "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" }, { toEncode5, sizeof(toEncode5), "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\r\n" }, + { toEncode6, sizeof(toEncode6), + "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh\r\n" + "YQA=\r\n" }, }; static const struct BinTests testsNoCR[] = { @@ -84,6 +88,9 @@ static const struct BinTests testsNoCR[] = { "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" }, { toEncode5, sizeof(toEncode5), "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\n" }, + { toEncode6, sizeof(toEncode6), + "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh\n" + "YQA=\n" }, }; static WCHAR *strdupAtoW(const char *str) @@ -93,7 +100,7 @@ static WCHAR *strdupAtoW(const char *str) if (!str) return ret; len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = heap_alloc(len * sizeof(WCHAR)); + ret = malloc(len * sizeof(WCHAR)); if (ret) MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); return ret; @@ -115,39 +122,36 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen, strLen = 0; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == required, "Unexpected required length %u, expected %u.\n", required, strLen); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == required, "Unexpected required length %lu, expected %lu.\n", required, strLen); strLen2 = strLen; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Unexpected required length.\n"); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length %lu, expected %lu.\n", strLen2, strLen); strLen2 = strLen - 1; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Unexpected required length.\n"); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length %lu, expected %lu.\n", strLen2, strLen); - str = heap_alloc(strLen); + str = malloc(strLen); /* Partially filled output buffer. */ strLen2 = strLen - 1; str[0] = 0x12; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); -todo_wine - ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %d.\n", + ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %ld.\n", ret, GetLastError()); - ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got %d\n", strLen - 1, strLen); -todo_wine { + ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %ld, got %ld\n", strLen, strLen2); if (header) ok(str[0] == header[0], "Unexpected buffer contents %#x.\n", str[0]); else ok(str[0] == expected[0], "Unexpected buffer contents %#x.\n", str[0]); -} strLen2 = strLen; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen2 == strLen - 1, "Expected length %ld, got %ld\n", strLen - 1, strLen2); ptr = str; if (header) @@ -160,7 +164,7 @@ todo_wine { if (trailer) ok(!strncmp(trailer, ptr, strlen(trailer)), "Expected trailer %s, got %s\n", trailer, ptr); - heap_free(str); + free(str); } static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWORD format, @@ -180,26 +184,26 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO strLen = 0; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); - ok(strLen == required, "Unexpected required length %u, expected %u.\n", strLen, required); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen == required, "Unexpected required length %lu, expected %u.\n", strLen, required); /* Same call with non-zero length value. */ strLen2 = strLen; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); ok(strLen == strLen2, "Unexpected required length.\n"); strLen2 = strLen - 1; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); ok(strLen == strLen2, "Unexpected required length.\n"); strLen2 = strLen - 1; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); ok(strLen == strLen2, "Unexpected required length.\n"); - strW = heap_alloc(strLen * sizeof(WCHAR)); + strW = malloc(strLen * sizeof(WCHAR)); headerW = strdupAtoW(header); trailerW = strdupAtoW(trailer); @@ -207,8 +211,7 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO strLen2 = strLen - 1; strW[0] = 0x1234; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2); -todo_wine - ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %d\n", + ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %ld\n", ret, GetLastError()); if (headerW) ok(strW[0] == 0x1234, "Unexpected buffer contents %#x.\n", strW[0]); @@ -217,9 +220,9 @@ todo_wine strLen2 = strLen; ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); - ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen); + ok(strLen2 == strLen - 1, "Expected length %ld, got %ld\n", strLen - 1, strLen); ptr = strW; if (headerW) @@ -235,24 +238,53 @@ todo_wine ok(!memcmp(trailerW, ptr, lstrlenW(trailerW)), "Expected trailer %s, got %s.\n", wine_dbgstr_w(trailerW), wine_dbgstr_w(ptr)); - heap_free(strW); - heap_free(headerW); - heap_free(trailerW); + free(strW); + free(headerW); + free(trailerW); +} + +static DWORD binary_to_hex_len(DWORD binary_len, DWORD flags) +{ + DWORD strLen2; + + strLen2 = binary_len * 3; /* spaces + terminating \0 */ + + if (flags & CRYPT_STRING_NOCR) + { + strLen2 += (binary_len + 7) / 16; /* space every 16 characters */ + strLen2 += 1; /* terminating \n */ + } + else if (!(flags & CRYPT_STRING_NOCRLF)) + { + strLen2 += (binary_len + 7) / 16; /* space every 16 characters */ + strLen2 += binary_len / 16 + 1; /* LF every 16 characters + terminating \r */ + + if (binary_len % 16) + strLen2 += 1; /* terminating \n */ + } + + return strLen2; } static void test_CryptBinaryToString(void) { - DWORD strLen, strLen2, i; + static const DWORD flags[] = { 0, CRYPT_STRING_NOCR, CRYPT_STRING_NOCRLF }; + static const DWORD sizes[] = { 3, 4, 7, 8, 12, 15, 16, 17, 256 }; + static const WCHAR hexdig[] = L"0123456789abcdef"; + BYTE input[256 * sizeof(WCHAR)]; + DWORD strLen, strLen2, i, j, k; + WCHAR *hex, *cmp, *ptr; + char *hex_a, *cmp_a; BOOL ret; ret = CryptBinaryToStringA(NULL, 0, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); strLen = 123; ret = CryptBinaryToStringA(NULL, 0, 0, NULL, &strLen); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); ok(strLen == 123, "Unexpected length.\n"); if (0) @@ -260,7 +292,7 @@ static void test_CryptBinaryToString(void) strLen = 123; ret = CryptBinaryToStringW(NULL, 0, 0, NULL, &strLen); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error %d\n", GetLastError()); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error %ld\n", GetLastError()); ok(strLen == 123, "Unexpected length.\n"); for (i = 0; i < ARRAY_SIZE(tests); i++) @@ -271,29 +303,29 @@ static void test_CryptBinaryToString(void) strLen = 0; ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen); strLen2 = strLen; - str = heap_alloc(strLen); + str = malloc(strLen); ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, str, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2); ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n"); - heap_free(str); + free(str); strLen = 0; ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); - ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen); strLen2 = strLen; - strW = heap_alloc(strLen); + strW = malloc(strLen); ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, strW, &strLen2); - ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2); ok(!memcmp(strW, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n"); - heap_free(strW); + free(strW); encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64, tests[i].base64, NULL, NULL); @@ -314,7 +346,7 @@ static void test_CryptBinaryToString(void) encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64X509CRLHEADER, encodedW, X509_HEADER, X509_TRAILER); - heap_free(encodedW); + free(encodedW); } for (i = 0; i < ARRAY_SIZE(testsNoCR); i++) @@ -325,16 +357,16 @@ static void test_CryptBinaryToString(void) ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, NULL, &strLen); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); strLen2 = strLen; - str = heap_alloc(strLen); + str = malloc(strLen); ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, str, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2); + ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2); ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen), "Unexpected value\n"); - heap_free(str); + free(str); encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, testsNoCR[i].base64, NULL, NULL); @@ -359,7 +391,245 @@ static void test_CryptBinaryToString(void) CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, encodedW, X509_HEADER_NOCR, X509_TRAILER_NOCR); - heap_free(encodedW); + free(encodedW); + } + + /* Systems that don't support HEXRAW format convert to BASE64 instead - 3 bytes in -> 4 chars + crlf + 1 null out. */ + strLen = 0; + ret = CryptBinaryToStringW(input, 3, CRYPT_STRING_HEXRAW, NULL, &strLen); + ok(ret, "Failed to get string length.\n"); + ok(strLen == 9 || broken(strLen == 7), "Unexpected string length %ld.\n", strLen); + if (strLen == 7) + { + win_skip("CryptBinaryToString(HEXRAW) not supported\n"); + return; + } + + for (i = 0; i < sizeof(input) / sizeof(WCHAR); i++) + ((WCHAR *)input)[i] = i; + + for (i = 0; i < ARRAY_SIZE(flags); i++) + { + winetest_push_context("i %lu", i); + strLen = 0; + ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen > 0, "Unexpected string length.\n"); + + strLen = 0; + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], NULL, &strLen); + ok(ret, "failed, error %ld.\n", GetLastError()); + ok(strLen > 0, "Unexpected string length.\n"); + + strLen = ~0; + ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], + NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + if (flags[i] & CRYPT_STRING_NOCRLF) + strLen2 = 0; + else if (flags[i] & CRYPT_STRING_NOCR) + strLen2 = 1; + else + strLen2 = 2; + strLen2 += sizeof(input) * 2 + 1; + ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen2, strLen); + + hex = malloc(strLen * sizeof(WCHAR)); + hex_a = malloc(strLen); + + memset(hex, 0xcc, strLen * sizeof(WCHAR)); + ptr = cmp = malloc(strLen * sizeof(WCHAR)); + cmp_a = malloc(strLen); + for (j = 0; j < ARRAY_SIZE(input); j++) + { + *ptr++ = hexdig[(input[j] >> 4) & 0xf]; + *ptr++ = hexdig[input[j] & 0xf]; + } + if (flags[i] & CRYPT_STRING_NOCR) + { + *ptr++ = '\n'; + } + else if (!(flags[i] & CRYPT_STRING_NOCRLF)) + { + *ptr++ = '\r'; + *ptr++ = '\n'; + } + *ptr++ = 0; + + for (j = 0; cmp[j]; ++j) + cmp_a[j] = cmp[j]; + cmp_a[j] = 0; + + ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], + hex, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + strLen2--; + ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2); + ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "Unexpected value\n"); + + ++strLen; + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW | flags[i], + hex_a, &strLen); + ok(ret, "failed, error %ld.\n", GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld.\n", strLen, strLen2); + ok(!memcmp(hex_a, cmp_a, strLen), "Unexpected value.\n"); + + /* adjusts size if buffer too big */ + strLen *= 2; + ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], + hex, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2); + + strLen *= 2; + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], + hex_a, &strLen); + ok(ret, "failed, error %ld.\n", GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld.\n", strLen, strLen2); + + /* no writes if buffer too small */ + strLen /= 2; + strLen2 /= 2; + memset(hex, 0xcc, strLen * sizeof(WCHAR)); + memset(cmp, 0xcc, strLen * sizeof(WCHAR)); + SetLastError(0xdeadbeef); + ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], + hex, &strLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%lu\n", + ret, GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2); + ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "Unexpected value\n"); + + SetLastError(0xdeadbeef); + memset(hex_a, 0xcc, strLen + 3); + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW | flags[i], + hex_a, &strLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA,"got ret %d, error %lu.\n", ret, GetLastError()); + ok(strLen == strLen2, "Expected length %ld, got %ld.\n", strLen2, strLen); + /* Output consists of the number of full bytes which fit in plus terminating 0. */ + strLen = (strLen - 1) & ~1; + ok(!memcmp(hex_a, cmp_a, strLen), "Unexpected value\n"); + ok(!hex_a[strLen], "got %#x.\n", (unsigned char)hex_a[strLen]); + ok((unsigned char)hex_a[strLen + 1] == 0xcc, "got %#x.\n", (unsigned char)hex_a[strLen + 1]); + + /* Output is not filled if string length is less than 3. */ + strLen = 1; + memset(hex_a, 0xcc, strLen2); + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW | flags[i], + hex_a, &strLen); + ok(strLen == 1, "got %ld.\n", strLen); + ok((unsigned char)hex_a[0] == 0xcc, "got %#x.\n", (unsigned char)hex_a[strLen - 1]); + + strLen = 2; + memset(hex_a, 0xcc, strLen2); + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW | flags[i], + hex_a, &strLen); + ok(strLen == 2, "got %ld.\n", strLen); + ok((unsigned char)hex_a[0] == 0xcc, "got %#x.\n", (unsigned char)hex_a[0]); + ok((unsigned char)hex_a[1] == 0xcc, "got %#x.\n", (unsigned char)hex_a[1]); + + strLen = 3; + memset(hex_a, 0xcc, strLen2); + ret = CryptBinaryToStringA(input, sizeof(input), CRYPT_STRING_HEXRAW | flags[i], + hex_a, &strLen); + ok(strLen == 3, "got %ld.\n", strLen); + ok(hex_a[0] == 0x30, "got %#x.\n", (unsigned char)hex_a[0]); + ok(hex_a[1] == 0x30, "got %#x.\n", (unsigned char)hex_a[1]); + ok(!hex_a[2], "got %#x.\n", (unsigned char)hex_a[2]); + + free(hex); + free(hex_a); + free(cmp); + free(cmp_a); + + winetest_pop_context(); + } + + for (k = 0; k < ARRAY_SIZE(sizes); k++) + for (i = 0; i < ARRAY_SIZE(flags); i++) + { + strLen = 0; + ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen > 0, "Unexpected string length.\n"); + + strLen = ~0; + ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + strLen2 = binary_to_hex_len(sizes[k], CRYPT_STRING_HEX | flags[i]); + ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen2, strLen); + + hex = malloc(strLen * sizeof(WCHAR) + 256); + memset(hex, 0xcc, strLen * sizeof(WCHAR)); + + ptr = cmp = malloc(strLen * sizeof(WCHAR) + 256); + for (j = 0; j < sizes[k]; j++) + { + *ptr++ = hexdig[(input[j] >> 4) & 0xf]; + *ptr++ = hexdig[input[j] & 0xf]; + + if (j >= sizes[k] - 1) break; + + if (j && !(flags[i] & CRYPT_STRING_NOCRLF)) + { + + if (!((j + 1) % 16)) + { + if (flags[i] & CRYPT_STRING_NOCR) + { + *ptr++ = '\n'; + } + else + { + *ptr++ = '\r'; + *ptr++ = '\n'; + } + continue; + } + else if (!((j + 1) % 8)) + *ptr++ = ' '; + } + + *ptr++ = ' '; + } + + if (flags[i] & CRYPT_STRING_NOCR) + { + *ptr++ = '\n'; + } + else if (!(flags[i] & CRYPT_STRING_NOCRLF)) + { + *ptr++ = '\r'; + *ptr++ = '\n'; + } + *ptr++ = 0; + + ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + strLen2--; + ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2); + ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%lu: got %s\n", i, wine_dbgstr_wn(hex, strLen)); + + /* adjusts size if buffer too big */ + strLen *= 2; + ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen); + ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError()); + ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2); + + /* no writes if buffer too small */ + strLen /= 2; + strLen2 /= 2; + memset(hex, 0xcc, strLen * sizeof(WCHAR)); + memset(cmp, 0xcc, strLen * sizeof(WCHAR)); + SetLastError(0xdeadbeef); + ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%lu\n", + ret, GetLastError()); + ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2); + ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%lu: got %s\n", i, wine_dbgstr_wn(hex, strLen)); + + free(hex); + free(cmp); } } @@ -375,7 +645,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, len += strlen(header); if (trailer) len += strlen(trailer); - str = HeapAlloc(GetProcessHeap(), 0, len); + str = malloc(len); if (str) { LPBYTE buf; @@ -391,8 +661,8 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, strcat(str, trailer); ret = CryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL, NULL); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufLen); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); + buf = malloc(bufLen); if (buf) { DWORD skipped, usedFormat; @@ -400,18 +670,18 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, /* check as normal, make sure last two parameters are optional */ ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL, NULL); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); ok(bufLen == expectedLen, - "Expected length %d, got %d\n", expectedLen, bufLen); + "Expected length %ld, got %ld\n", expectedLen, bufLen); ok(!memcmp(buf, expected, bufLen), "Unexpected value\n"); /* check last two params */ ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, &skipped, &usedFormat); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); - ok(skipped == 0, "Expected skipped 0, got %d\n", skipped); - ok(usedFormat == expectedFormat, "Expected format %d, got %d\n", + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); + ok(skipped == 0, "Expected skipped 0, got %ld\n", skipped); + ok(usedFormat == expectedFormat, "Expected format %ld, got %ld\n", expectedFormat, usedFormat); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* Check again, but with garbage up front */ @@ -425,27 +695,27 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, NULL); /* expect failure with no header, and success with one */ if (header) - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); else ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%d\n", ret, GetLastError()); + "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%ld\n", ret, GetLastError()); if (ret) { - buf = HeapAlloc(GetProcessHeap(), 0, bufLen); + buf = malloc(bufLen); if (buf) { DWORD skipped, usedFormat; ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, &skipped, &usedFormat); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); ok(skipped == strlen(garbage), - "Expected %d characters of \"%s\" skipped when trying format %08x, got %d (used format is %08x)\n", + "Expected %d characters of \"%s\" skipped when trying format %08lx, got %ld (used format is %08lx)\n", lstrlenA(garbage), str, useFormat, skipped, usedFormat); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } } - HeapFree(GetProcessHeap(), 0, str); + free(str); } } @@ -474,14 +744,14 @@ static void decodeBase64WithLenFmt(LPCSTR str, int len, DWORD fmt, LPCSTR expect if (expected) { BOOL correct = ret && strcmp(expected, (char*)buf) == 0; ok(correct || (isBroken && broken(!ret)), - "base64 \"%s\" len %d: expected \"%s\", got \"%s\" (ret %d, le %d)\n", + "base64 \"%s\" len %d: expected \"%s\", got \"%s\" (ret %d, le %ld)\n", str, len, expected, (char*)buf, ret, GetLastError()); if (correct) - ok(fmtUsed == fmt, "base64 \"%s\" len %d: expected fmt %d, used %d\n", + ok(fmtUsed == fmt, "base64 \"%s\" len %d: expected fmt %ld, used %ld\n", str, len, fmt, fmtUsed); } else { ok(!ret && GetLastError() == le, - "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %d)\n", + "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %ld)\n", str, len, (char*)buf, ret, GetLastError()); } @@ -513,28 +783,162 @@ static const struct BadString badStrings[] = { { "-----BEGIN X509 CRL-----\r\nAA==\r\n", CRYPT_STRING_BASE64X509CRLHEADER }, }; -static void testStringToBinaryA(void) +static BOOL is_hex_string_special_char(WCHAR c) { - BOOL ret; + switch (c) + { + case '-': + case ',': + case ' ': + case '\t': + case '\r': + case '\n': + return TRUE; + + default: + return FALSE; + } +} + +static WCHAR wchar_from_str(BOOL wide, const void **str, DWORD *len) +{ + WCHAR c; + + if (!*len) + return 0; + + --*len; + if (wide) + c = *(*(const WCHAR **)str)++; + else + c = *(*(const char **)str)++; + + return c ? c : 0xffff; +} + +static BYTE digit_from_char(WCHAR c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + c = towlower(c); + if (c >= 'a' && c <= 'f') + return c - 'a' + 0xa; + return 0xff; +} + +static LONG string_to_hex(const void* str, BOOL wide, DWORD len, BYTE *hex, DWORD *hex_len, + DWORD *skipped, DWORD *ret_flags) +{ + unsigned int byte_idx = 0; + BYTE d1, d2; + WCHAR c; + + if (!str || !hex_len) + return ERROR_INVALID_PARAMETER; + + if (!len) + len = wide ? wcslen(str) : strlen(str); + + if (wide && !len) + return ERROR_INVALID_PARAMETER; + + if (skipped) + *skipped = 0; + if (ret_flags) + *ret_flags = 0; + + while ((c = wchar_from_str(wide, &str, &len)) && is_hex_string_special_char(c)) + ; + + while ((d1 = digit_from_char(c)) != 0xff) + { + if ((d2 = digit_from_char(wchar_from_str(wide, &str, &len))) == 0xff) + { + if (!hex) + *hex_len = 0; + return ERROR_INVALID_DATA; + } + + if (hex && byte_idx < *hex_len) + hex[byte_idx] = (d1 << 4) | d2; + + ++byte_idx; + + do + { + c = wchar_from_str(wide, &str, &len); + } while (c == '-' || c == ','); + } + + while (c) + { + if (!is_hex_string_special_char(c)) + { + if (!hex) + *hex_len = 0; + return ERROR_INVALID_DATA; + } + c = wchar_from_str(wide, &str, &len); + } + + if (hex && byte_idx > *hex_len) + return ERROR_MORE_DATA; + + if (ret_flags) + *ret_flags = CRYPT_STRING_HEX; + + *hex_len = byte_idx; + + return ERROR_SUCCESS; +} + +static void test_CryptStringToBinary(void) +{ + static const char *string_hex_tests[] = + { + "", + "-", + ",-", + "0", + "00", + "000", + "11220", + "1122q", + "q1122", + " aE\t\n\r\n", + "01-02", + "-,01-02", + "01-02-", + "aa,BB-ff,-,", + "1-2", + "010-02", + "aa,BBff,-,", + "aa,,-BB---ff,-,", + "010203040506070809q", + }; + + DWORD skipped, flags, expected_err, expected_len, expected_skipped, expected_flags; + BYTE buf[8], expected[8]; DWORD bufLen = 0, i; - BYTE buf[8]; + WCHAR str_w[64]; + BOOL ret, wide; ret = CryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%lu\n", ret, GetLastError()); ret = CryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%lu\n", ret, GetLastError()); /* Bogus format */ ret = CryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError()); + "Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", ret, GetLastError()); /* Decoding doesn't expect the NOCR flag to be specified */ ret = CryptStringToBinaryA(tests[0].base64, 1, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError()); + "Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", ret, GetLastError()); /* Bad strings */ for (i = 0; i < ARRAY_SIZE(badStrings); i++) { @@ -542,7 +946,7 @@ static void testStringToBinaryA(void) ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "%d: Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", i, ret, GetLastError()); + "%ld: Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", i, ret, GetLastError()); } /* Weird base64 strings (invalid padding, extra white-space etc.) */ decodeBase64WithLen("V=", 0, 0, ERROR_INVALID_DATA); @@ -599,7 +1003,7 @@ static void testStringToBinaryA(void) bufLen = 4; ret = CryptStringToBinaryA("VVVVVVVV", 8, CRYPT_STRING_BASE64, (BYTE*)buf, &bufLen, NULL, NULL); ok(!ret && bufLen == 4 && buf[0] == 0, - "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %d, buf[0] '%c'\n", + "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %ld, buf[0] '%c'\n", ret, bufLen, buf[0]); /* Good strings */ @@ -611,7 +1015,7 @@ static void testStringToBinaryA(void) */ ret = CryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64, NULL, &bufLen, NULL, NULL); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); /* Check with the precise format */ decodeAndCompareBase64_A(tests[i].base64, NULL, NULL, CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, tests[i].toEncode, @@ -668,7 +1072,7 @@ static void testStringToBinaryA(void) */ ret = CryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64, NULL, &bufLen, NULL, NULL); - ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); + ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError()); /* Check with the precise format */ decodeAndCompareBase64_A(testsNoCR[i].base64, NULL, NULL, CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, testsNoCR[i].toEncode, @@ -697,10 +1101,254 @@ static void testStringToBinaryA(void) CRYPT_STRING_ANY, CRYPT_STRING_BASE64HEADER, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen); } + + /* CRYPT_STRING_HEX */ + + ret = CryptStringToBinaryW(L"01", 2, CRYPT_STRING_HEX, NULL, NULL, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got ret %d, error %lu.\n", ret, GetLastError()); + if (0) + { + /* access violation on Windows. */ + CryptStringToBinaryA("01", 2, CRYPT_STRING_HEX, NULL, NULL, NULL, NULL); + } + + bufLen = 8; + ret = CryptStringToBinaryW(L"0102", 2, CRYPT_STRING_HEX, NULL, &bufLen, NULL, NULL); + ok(ret, "got error %lu.\n", GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + + bufLen = 8; + ret = CryptStringToBinaryW(NULL, 0, CRYPT_STRING_HEX, NULL, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 8, "got length %lu.\n", bufLen); + + bufLen = 8; + ret = CryptStringToBinaryA(NULL, 0, CRYPT_STRING_HEX, NULL, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 8, "got length %lu.\n", bufLen); + + bufLen = 8; + ret = CryptStringToBinaryW(L"0102", 3, CRYPT_STRING_HEX, NULL, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(!bufLen, "got length %lu.\n", bufLen); + + bufLen = 8; + buf[0] = 0xcc; + ret = CryptStringToBinaryW(L"0102", 3, CRYPT_STRING_HEX, buf, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 8, "got length %lu.\n", bufLen); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + + bufLen = 8; + buf[0] = 0xcc; + ret = CryptStringToBinaryW(L"0102", 2, CRYPT_STRING_HEX, buf, &bufLen, NULL, NULL); + ok(ret, "got error %lu.\n", GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + + bufLen = 8; + buf[0] = buf[1] = 0xcc; + ret = CryptStringToBinaryA("01\0 02", 4, CRYPT_STRING_HEX, buf, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 8, "got length %lu.\n", bufLen); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + bufLen = 8; + buf[0] = buf[1] = 0xcc; + ret = CryptStringToBinaryW(L"01\0 02", 4, CRYPT_STRING_HEX, buf, &bufLen, NULL, NULL); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 8, "got length %lu.\n", bufLen); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + bufLen = 1; + buf[0] = 0xcc; + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + ret = CryptStringToBinaryW(L"0102", 4, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(!ret && GetLastError() == ERROR_MORE_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(!flags, "got flags %lu.\n", flags); + ok(!skipped, "got skipped %lu.\n", skipped); + + for (i = 0; i < ARRAY_SIZE(string_hex_tests); ++i) + { + for (wide = 0; wide < 2; ++wide) + { + if (wide) + { + unsigned int j = 0; + + while ((str_w[j] = string_hex_tests[i][j])) + ++j; + } + winetest_push_context("test %lu, %s", i, wide ? debugstr_w(str_w) + : debugstr_a(string_hex_tests[i])); + + expected_len = 0xdeadbeef; + expected_skipped = 0xdeadbeef; + expected_flags = 0xdeadbeef; + expected_err = string_to_hex(wide ? (void *)str_w : (void *)string_hex_tests[i], wide, 0, NULL, + &expected_len, &expected_skipped, &expected_flags); + + bufLen = 0xdeadbeef; + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + SetLastError(0xdeadbeef); + if (wide) + ret = CryptStringToBinaryW(str_w, 0, CRYPT_STRING_HEX, NULL, &bufLen, &skipped, &flags); + else + ret = CryptStringToBinaryA(string_hex_tests[i], 0, CRYPT_STRING_HEX, NULL, &bufLen, &skipped, &flags); + + ok(bufLen == expected_len, "got length %lu.\n", bufLen); + ok(skipped == expected_skipped, "got skipped %lu.\n", skipped); + ok(flags == expected_flags, "got flags %lu.\n", flags); + + if (expected_err) + ok(!ret && GetLastError() == expected_err, "got ret %d, error %lu.\n", ret, GetLastError()); + else + ok(ret, "got error %lu.\n", GetLastError()); + + memset(expected, 0xcc, sizeof(expected)); + expected_len = 8; + expected_skipped = 0xdeadbeef; + expected_flags = 0xdeadbeef; + expected_err = string_to_hex(wide ? (void *)str_w : (void *)string_hex_tests[i], wide, 0, expected, + &expected_len, &expected_skipped, &expected_flags); + + memset(buf, 0xcc, sizeof(buf)); + bufLen = 8; + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + SetLastError(0xdeadbeef); + if (wide) + ret = CryptStringToBinaryW(str_w, 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + else + ret = CryptStringToBinaryA(string_hex_tests[i], 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + + ok(!memcmp(buf, expected, sizeof(buf)), "data does not match, buf[0] %#x, buf[1] %#x.\n", buf[0], buf[1]); + ok(bufLen == expected_len, "got length %lu.\n", bufLen); + if (expected_err) + ok(!ret && GetLastError() == expected_err, "got ret %d, error %lu.\n", ret, GetLastError()); + else + ok(ret, "got error %lu.\n", GetLastError()); + + ok(bufLen == expected_len, "got length %lu.\n", bufLen); + ok(skipped == expected_skipped, "got skipped %lu.\n", skipped); + ok(flags == expected_flags, "got flags %lu.\n", flags); + + winetest_pop_context(); + } + } + + bufLen = 1; + SetLastError(0xdeadbeef); + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + memset(buf, 0xcc, sizeof(buf)); + ret = CryptStringToBinaryA("0102", 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(!ret && GetLastError() == ERROR_MORE_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(!skipped, "got skipped %lu.\n", skipped); + ok(!flags, "got flags %lu.\n", flags); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + bufLen = 1; + SetLastError(0xdeadbeef); + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + memset(buf, 0xcc, sizeof(buf)); + ret = CryptStringToBinaryA("0102q", 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(!skipped, "got skipped %lu.\n", skipped); + ok(!flags, "got flags %lu.\n", flags); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + bufLen = 1; + SetLastError(0xdeadbeef); + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + memset(buf, 0xcc, sizeof(buf)); + ret = CryptStringToBinaryW(L"0102q", 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(!skipped, "got skipped %lu.\n", skipped); + ok(!flags, "got flags %lu.\n", flags); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + bufLen = 1; + SetLastError(0xdeadbeef); + skipped = 0xdeadbeef; + flags = 0xdeadbeef; + memset(buf, 0xcc, sizeof(buf)); + ret = CryptStringToBinaryW(L"0102", 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(bufLen == 1, "got length %lu.\n", bufLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + ok(buf[0] == 1, "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + + /* It looks like Windows is normalizing Unicode strings in some way which depending on locale may result in + * some invalid characters in 128-255 range being converted into sequences starting with valid hex numbers. + * Just avoiding characters in the 128-255 range in test. */ + for (i = 1; i < 128; ++i) + { + char str_a[16]; + + for (wide = 0; wide < 2; ++wide) + { + if (wide) + { + str_w[0] = i; + wcscpy(str_w + 1, L"00"); + } + else + { + str_a[0] = i; + strcpy(str_a + 1, "00"); + } + + winetest_push_context("char %#lx, %s", i, wide ? debugstr_w(str_w) : debugstr_a(str_a)); + + bufLen = 1; + buf[0] = buf[1] = 0xcc; + SetLastError(0xdeadbeef); + if (wide) + ret = CryptStringToBinaryW(str_w, 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + else + ret = CryptStringToBinaryA(str_a, 0, CRYPT_STRING_HEX, buf, &bufLen, &skipped, &flags); + ok(bufLen == 1, "got length %lu.\n", bufLen); + if (is_hex_string_special_char(i)) + { + ok(ret, "got error %lu.\n", GetLastError()); + ok(!buf[0], "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[1] %#x.\n", buf[1]); + } + else + { + ok(!ret && GetLastError() == ERROR_INVALID_DATA, "got ret %d, error %lu.\n", ret, GetLastError()); + if (isdigit(i) || (tolower(i) >= 'a' && tolower(i) <= 'f')) + { + ok(buf[0] == (digit_from_char(i) << 4), "got buf[0] %#x.\n", buf[0]); + ok(buf[1] == 0xcc, "got buf[0] %#x.\n", buf[1]); + } + else + { + ok(buf[0] == 0xcc, "got buf[0] %#x.\n", buf[0]); + } + } + winetest_pop_context(); + } + } } START_TEST(base64) { test_CryptBinaryToString(); - testStringToBinaryA(); + test_CryptStringToBinary(); } diff --git a/modules/rostests/winetests/crypt32/cert.c b/modules/rostests/winetests/crypt32/cert.c index f653741ea72..5533ba1ec68 100644 --- a/modules/rostests/winetests/crypt32/cert.c +++ b/modules/rostests/winetests/crypt32/cert.c @@ -21,45 +21,17 @@ #include #include +#include +#define WIN32_NO_STATUS #include #include #include #include #include +#include #include "wine/test.h" -static PCCERT_CONTEXT (WINAPI *pCertCreateSelfSignCertificate)(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE,PCERT_NAME_BLOB,DWORD,PCRYPT_KEY_PROV_INFO,PCRYPT_ALGORITHM_IDENTIFIER,PSYSTEMTIME,PSYSTEMTIME,PCERT_EXTENSIONS); -static BOOL (WINAPI *pCertGetValidUsages)(DWORD,PCCERT_CONTEXT*,int*,LPSTR*,DWORD*); -static BOOL (WINAPI *pCryptAcquireCertificatePrivateKey)(PCCERT_CONTEXT,DWORD,void*,HCRYPTPROV_OR_NCRYPT_KEY_HANDLE*,DWORD*,BOOL*); -static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); -static BOOL (WINAPI * pCryptVerifyCertificateSignatureEx) - (HCRYPTPROV, DWORD, DWORD, void *, DWORD, void *, DWORD, void *); - -static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); - -static void init_function_pointers(void) -{ - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hCrypt32, CertCreateSelfSignCertificate) - GET_PROC(hCrypt32, CertGetValidUsages) - GET_PROC(hCrypt32, CryptAcquireCertificatePrivateKey) - GET_PROC(hCrypt32, CryptEncodeObjectEx) - GET_PROC(hCrypt32, CryptVerifyCertificateSignatureEx) - - GET_PROC(hAdvapi32, CryptAcquireContextA) - -#undef GET_PROC -} - static BYTE subjectName[] = { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00 }; @@ -150,28 +122,22 @@ static void testAddCert(void) store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); if (!store) return; - /* Weird--bad add disposition leads to an access violation in Windows. - * Both tests crash on some win9x boxes. - */ - if (0) - { - ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, - sizeof(bigCert), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", - GetLastError()); - ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, - bigCert, sizeof(bigCert), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", - GetLastError()); - } + ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, + sizeof(bigCert), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", + GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, + bigCert, sizeof(bigCert), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", + GetLastError()); /* Weird--can add a cert to the NULL store (does this have special * meaning?) @@ -179,28 +145,21 @@ static void testAddCert(void) context = NULL; ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); - if (context) - CertFreeCertificateContext(context); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + CertFreeCertificateContext(context); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* This has the same name as bigCert, so finding isn't done by name */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a context\n"); if (context) @@ -215,7 +174,7 @@ static void testAddCert(void) /* Set the same hash as bigCert2, and try to readd it */ ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0, &hash); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); ret = CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_NEW, NULL); @@ -234,7 +193,7 @@ static void testAddCert(void) ret = CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_NEW, NULL); ok(!ret && GetLastError() == CRYPT_E_EXISTS, - "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError()); + "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError()); CertFreeCertificateContext(context); } @@ -245,7 +204,7 @@ static void testAddCert(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2WithDifferentSerial, sizeof(bigCert2WithDifferentSerial), CERT_STORE_ADD_NEW, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); if (context) CertDeleteCertificateFromStore(context); @@ -257,7 +216,7 @@ static void testAddCert(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCertWithDifferentSubject, sizeof(bigCertWithDifferentSubject), CERT_STORE_ADD_NEW, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); if (context) CertDeleteCertificateFromStore(context); @@ -269,14 +228,14 @@ static void testAddCert(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer), CERT_STORE_ADD_NEW, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); if (context) CertDeleteCertificateFromStore(context); collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(collection != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(collection != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (collection) { /* Add store to the collection, but disable updates */ @@ -291,19 +250,19 @@ static void testAddCert(void) ret = CertAddCertificateContextToStore(collection, context, CERT_STORE_ADD_NEW, NULL); ok(!ret && GetLastError() == CRYPT_E_EXISTS, - "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError()); + "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError()); /* Replacing an existing certificate context is allowed, even * though updates to the collection aren't.. */ ret = CertAddCertificateContextToStore(collection, context, CERT_STORE_ADD_REPLACE_EXISTING, NULL); - ok(ret, "CertAddCertificateContextToStore failed: %08x\n", + ok(ret, "CertAddCertificateContextToStore failed: %08lx\n", GetLastError()); /* use the existing certificate and ask for a copy of the context*/ copyContext = NULL; ret = CertAddCertificateContextToStore(collection, context, CERT_STORE_ADD_USE_EXISTING, ©Context); - ok(ret, "CertAddCertificateContextToStore failed: %08x\n", + ok(ret, "CertAddCertificateContextToStore failed: %08lx\n", GetLastError()); ok(copyContext != NULL, "Expected on output a non NULL copyContext\n"); if (copyContext) @@ -312,7 +271,7 @@ static void testAddCert(void) ret = CertAddCertificateContextToStore(collection, context, CERT_STORE_ADD_ALWAYS, NULL); ok(!ret && GetLastError() == E_ACCESSDENIED, - "Expected E_ACCESSDENIED, got %08x\n", GetLastError()); + "Expected E_ACCESSDENIED, got %08lx\n", GetLastError()); CertFreeCertificateContext(context); } @@ -334,23 +293,22 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, memset(hashProperty, 0, sizeof(hashProperty)); size = sizeof(hash); ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ret = CertGetCertificateContextProperty(context, propID, NULL, &dwSizeWithNull); - ok(ret, "algID %08x, propID %d: CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "algID %08x, propID %ld: CertGetCertificateContextProperty failed: %08lx\n", algID, propID, GetLastError()); ret = CertGetCertificateContextProperty(context, propID, hashProperty, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n", + ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n", propID); - ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %d instead of %d\n", + ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %ld instead of %ld\n", dwSizeWithNull,size); } static const CHAR cspNameA[] = "WineCryptTemp"; -static WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e','m','p',0 }; static const BYTE v1CertWithPubKey[] = { 0x30,0x81,0x95,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30, 0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61, @@ -411,15 +369,13 @@ static void testCertProperties(void) BYTE hash[20] = { 0 }, hashProperty[20]; CRYPT_DATA_BLOB blob; CERT_KEY_CONTEXT keyContext; + unsigned int value; - ok(context != NULL || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertCreateCertificateContext failed: %08x\n", GetLastError()); - if (!context) - return; + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); /* This crashes propID = CertEnumCertificateContextProperties(NULL, 0); - */ + */ propID = 0; numProps = 0; @@ -428,12 +384,12 @@ static void testCertProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 0, "Expected 0 properties, got %d\n", numProps); + ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps); /* Tests with a NULL cert context. Prop ID 0 fails.. */ ret = CertSetCertificateContextProperty(NULL, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* while this just crashes. ret = CertSetCertificateContextProperty(NULL, CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL); @@ -441,7 +397,7 @@ static void testCertProperties(void) ret = CertSetCertificateContextProperty(context, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Can't set the cert property directly, this crashes. ret = CertSetCertificateContextProperty(context, CERT_CERT_PROP_ID, 0, bigCert2); @@ -460,12 +416,12 @@ static void testCertProperties(void) ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* And, an implicit property */ size = sizeof(access); ret = CertGetCertificateContextProperty(context, CERT_ACCESS_STATE_PROP_ID, &access, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG), "Didn't expect a persisted cert\n"); @@ -480,18 +436,18 @@ static void testCertProperties(void) blob.cbData = sizeof(hash); ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0, &blob); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); size = sizeof(hashProperty); ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID, hashProperty, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n"); /* Delete the (bogus) hash, and get the real one */ ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0, NULL); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); checkHash(bigCert, sizeof(bigCert), CALG_SHA1, context, CERT_HASH_PROP_ID); @@ -506,7 +462,7 @@ static void testCertProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 1, "Expected 1 properties, got %d\n", numProps); + ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps); /* Check a few other implicit properties */ checkHash(bigCert, sizeof(bigCert), CALG_MD5, context, @@ -516,61 +472,58 @@ static void testCertProperties(void) size = 0; ret = CertGetCertificateContextProperty(context, CERT_SIGNATURE_HASH_PROP_ID, NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); /* Test key contexts and handles and such */ size = 0; ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); size = sizeof(CERT_KEY_CONTEXT); ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Key context with an invalid size */ keyContext.cbSize = 0; ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); size = sizeof(keyContext); ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); keyContext.cbSize = sizeof(keyContext); keyContext.hCryptProv = 0; keyContext.dwKeySpec = AT_SIGNATURE; ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); /* Now that that's set, the key prov handle property is also gettable. */ size = sizeof(keyContext.hCryptProv); ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_HANDLE_PROP_ID, &keyContext.hCryptProv, &size); - ok(ret, "Expected to get the CERT_KEY_PROV_HANDLE_PROP_ID, got %08x\n", + ok(ret, "Expected to get the CERT_KEY_PROV_HANDLE_PROP_ID, got %08lx\n", GetLastError()); /* Remove the key prov handle property.. */ ret = CertSetCertificateContextProperty(context, CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); /* and the key context's CSP is set to NULL. */ size = sizeof(keyContext); ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n"); @@ -581,7 +534,7 @@ static void testCertProperties(void) ret = CertGetCertificateContextProperty(context, CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError()); CertFreeCertificateContext(context); /* This cert does have a public key, but its subject key identifier still * isn't available: */ @@ -590,7 +543,7 @@ static void testCertProperties(void) ret = CertGetCertificateContextProperty(context, CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_DATA, - "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError()); CertFreeCertificateContext(context); /* This cert with a subject key extension can have its key identifier * property retrieved: @@ -599,21 +552,40 @@ static void testCertProperties(void) v1CertWithSubjectKeyId, sizeof(v1CertWithSubjectKeyId)); ret = CertGetCertificateContextProperty(context, CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); if (ret) { - LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size); + LPBYTE buf = malloc(size); if (buf) { ret = CertGetCertificateContextProperty(context, CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); ok(!memcmp(buf, subjectKeyId, size), "Unexpected subject key id\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } } + + ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, NULL, &size); + ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "got ret %d, error %#lx.\n", ret, GetLastError()); + + blob.cbData = sizeof(value); + blob.pbData = (BYTE *)&value; + value = 1; + ret = CertSetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, 0, &blob); + ok(ret, "got error %#lx.\n", GetLastError()); + value = 0xdeadbeef; + size = 0xdeadbeef; + ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, NULL, &size); + ok(ret, "got error %#lx.\n", GetLastError()); + ok(size == sizeof(value), "got size %lu.\n", size); + ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, &value, &size); + ok(ret, "got error %#lx.\n", GetLastError()); + ok(size == sizeof(value), "got size %lu.\n", size); + ok(value == 1, "got value %u.\n", value); + CertFreeCertificateContext(context); context = CertCreateCertificateContext(X509_ASN_ENCODING, @@ -622,8 +594,8 @@ static void testCertProperties(void) size = 0; ret = CertGetCertificateContextProperty(context, CERT_SIGNATURE_HASH_PROP_ID, NULL, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError()); - ok(size == sizeof(selfSignedSignatureHash), "unexpected size %d\n", size); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); + ok(size == sizeof(selfSignedSignatureHash), "unexpected size %ld\n", size); ret = CertGetCertificateContextProperty(context, CERT_SIGNATURE_HASH_PROP_ID, hashProperty, &size); if (ret) @@ -641,22 +613,20 @@ static void testCreateCert(void) SetLastError(0xdeadbeef); cert = CertCreateCertificateContext(0, NULL, 0); ok(!cert && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); cert = CertCreateCertificateContext(0, selfSignedCert, sizeof(selfSignedCert)); ok(!cert && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); cert = CertCreateCertificateContext(X509_ASN_ENCODING, NULL, 0); - ok(!cert && - (GetLastError() == CRYPT_E_ASN1_EOD || - broken(GetLastError() == OSS_MORE_INPUT /* NT4 */)), - "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!cert && GetLastError() == CRYPT_E_ASN1_EOD, + "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); - ok(cert != NULL, "creating cert failed: %08x\n", GetLastError()); + ok(cert != NULL, "creating cert failed: %08lx\n", GetLastError()); /* Even in-memory certs are expected to have a store associated with them */ ok(cert->hCertStore != NULL, "expected created cert to have a store\n"); /* The cert doesn't have the archived property set (which would imply it @@ -666,13 +636,13 @@ static void testCreateCert(void) ret = CertGetCertificateContextProperty(cert, CERT_ARCHIVED_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Strangely, enumerating the certs in the store finds none. */ enumCert = NULL; count = 0; while ((enumCert = CertEnumCertificatesInStore(cert->hCertStore, enumCert))) count++; - ok(!count, "expected 0, got %d\n", count); + ok(!count, "expected 0, got %ld\n", count); CertFreeCertificateContext(cert); } @@ -684,24 +654,18 @@ static void testDupCert(void) store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); if (!store) return; ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a valid cert context\n"); if (context) { ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong cert size %d\n", context->cbCertEncoded); + "Wrong cert size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)), "Unexpected encoded cert in context\n"); ok(context->hCertStore == store, "Unexpected store\n"); @@ -727,7 +691,7 @@ static void testDupCert(void) ok(ret, "CertFreeCertificateContext failed\n"); store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ret = CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_NEW, &storeContext); ok(ret, "CertAddCertificateContextToStore failed\n"); @@ -739,7 +703,7 @@ static void testDupCert(void) ok(storeContext->pCertInfo != context->pCertInfo, "unexpected pCertInfo\n"); store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store2 != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ret = CertAddCertificateContextToStore(store2, storeContext, CERT_STORE_ADD_NEW, &storeContext2); ok(ret, "CertAddCertificateContextToStore failed\n"); @@ -783,7 +747,7 @@ static void testLinkCert(void) ok(context != NULL, "CertCreateCertificateContext failed\n"); store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ret = CertAddCertificateLinkToStore(store, context, CERT_STORE_ADD_NEW, &link); ok(ret, "CertAddCertificateContextToStore failed\n"); @@ -1137,33 +1101,25 @@ static void testFindCert(void) CRYPT_HASH_BLOB blob; BYTE otherSerialNumber[] = { 2 }; DWORD count; - static const WCHAR juan[] = { 'j','u','a','n',0 }; - static const WCHAR lang[] = { 'L','A','N','G',0 }; - static const WCHAR malcolm[] = { 'm','a','l','c','o','l','m',0 }; store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); if (!store) return; ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_NEW, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* This has the same name as bigCert */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* Crashes @@ -1177,7 +1133,7 @@ static void testFindCert(void) certInfo.SerialNumber.cbData = sizeof(serialNum); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_ISSUER_NAME, &certInfo.Subject, NULL); - ok(context != NULL, "CertFindCertificateInStore failed: %08x\n", + ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n", GetLastError()); if (context) { @@ -1197,7 +1153,7 @@ static void testFindCert(void) certInfo.Subject.cbData = sizeof(subjectName2); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_NAME, &certInfo.Subject, NULL); - ok(context != NULL, "CertFindCertificateInStore failed: %08x\n", + ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n", GetLastError()); if (context) { @@ -1218,7 +1174,7 @@ static void testFindCert(void) certInfo.Issuer.cbData = sizeof(subjectName2); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_CERT, &certInfo, NULL); - ok(context != NULL, "CertFindCertificateInStore failed: %08x\n", + ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n", GetLastError()); if (context) { @@ -1251,7 +1207,7 @@ static void testFindCert(void) blob.cbData = sizeof(bigCertHash); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_SHA1_HASH, &blob, NULL); - ok(context != NULL, "CertFindCertificateInStore failed: %08x\n", + ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n", GetLastError()); if (context) { @@ -1274,7 +1230,7 @@ static void testFindCert(void) context = NULL; do { context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, juan, context); + CERT_FIND_ISSUER_STR, L"juan", context); if (context) count++; } while (context); @@ -1283,17 +1239,17 @@ static void testFindCert(void) context = NULL; do { context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, lang, context); + CERT_FIND_ISSUER_STR, L"LANG", context); if (context) count++; } while (context); ok(count == 3, "expected 3 contexts\n"); SetLastError(0xdeadbeef); context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, - CERT_FIND_ISSUER_STR, malcolm, NULL); + CERT_FIND_ISSUER_STR, L"malcolm", NULL); ok(!context, "expected no certs\n"); ok(GetLastError() == CRYPT_E_NOT_FOUND, - "expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); CertCloseStore(store, 0); @@ -1302,19 +1258,19 @@ static void testFindCert(void) CERT_STORE_CREATE_NEW_FLAG, NULL); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, iTunesCert0, sizeof(iTunesCert0), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, iTunesCert1, sizeof(iTunesCert1), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, iTunesCert2, sizeof(iTunesCert2), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, iTunesCert3, sizeof(iTunesCert3), CERT_STORE_ADD_NEW, &subject); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* The certInfo's issuer does not match any subject, but the serial @@ -1368,49 +1324,44 @@ static void testGetSubjectCert(void) store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); if (!store) return; ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */), - "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - skip("bigCert can't be decoded, skipping tests\n"); - return; - } + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); + ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, &context1); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context1 != NULL, "Expected a context\n"); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING, NULL); ok(!context2 && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING, &info); ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = serialNum; context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING, &info); ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); info.Issuer.cbData = sizeof(subjectName2); info.Issuer.pbData = subjectName2; context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING, &info); ok(context2 != NULL, - "CertGetSubjectCertificateFromStore failed: %08x\n", GetLastError()); + "CertGetSubjectCertificateFromStore failed: %08lx\n", GetLastError()); /* Not only should this find a context, but it should be the same * (same address) as context1. */ @@ -1566,21 +1517,19 @@ static void testGetIssuerCert(void) DWORD flags = 0xffffffff, size; CERT_NAME_BLOB certsubject; BYTE *certencoded; - WCHAR rootW[] = {'R', 'O', 'O', 'T', '\0'}, - certname[] = {'C', 'N', '=', 'd', 'u', 'm', 'm', 'y', ',', ' ', 'T', '=', 'T', 'e', 's', 't', '\0'}; HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, expiredCert, sizeof(expiredCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, childOfExpired, sizeof(childOfExpired), CERT_STORE_ADD_ALWAYS, &child); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* These crash: @@ -1589,13 +1538,13 @@ static void testGetIssuerCert(void) */ parent = CertGetIssuerCertificateFromStore(NULL, NULL, NULL, &flags); ok(!parent && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, NULL, NULL, &flags); ok(!parent && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(!parent && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Confusing: the caller cannot set either of the * CERT_STORE_NO_*_FLAGs, as these are not checks, * they're results: @@ -1603,24 +1552,24 @@ static void testGetIssuerCert(void) flags = CERT_STORE_NO_CRL_FLAG | CERT_STORE_NO_ISSUER_FLAG; parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(!parent && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Perform no checks */ flags = 0; parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); - ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08x\n", + ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n", GetLastError()); if (parent) CertFreeCertificateContext(parent); /* Check revocation and signature only */ flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG; parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); - ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08x\n", + ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n", GetLastError()); /* Confusing: CERT_STORE_REVOCATION_FLAG succeeds when there is no CRL by * setting CERT_STORE_NO_CRL_FLAG. */ ok(flags == (CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG), - "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08x\n", + "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n", flags); if (parent) CertFreeCertificateContext(parent); @@ -1639,33 +1588,33 @@ static void testGetIssuerCert(void) /* With only the child certificate, no issuer will be found */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == NULL, "Expected no issuer\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); /* Adding an issuer allows one (and only one) issuer to be found */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert1); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == cert1, "Expected cert1 to be the issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == NULL, "Expected only one issuer\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); /* Adding a second issuer allows two issuers to be found - and the second * issuer is found before the first, implying certs are added to the head * of a list. */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert2); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == cert2, "Expected cert2 to be the first issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == cert1, "Expected cert1 to be the second issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == NULL, "Expected no more than two issuers\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); CertFreeCertificateContext(child); CertFreeCertificateContext(cert1); CertFreeCertificateContext(cert2); @@ -1679,47 +1628,47 @@ static void testGetIssuerCert(void) /* With only the child certificate, no issuer will be found */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == NULL, "Expected no issuer\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); /* Adding an issuer allows one (and only one) issuer to be found */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert1); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == cert1, "Expected cert1 to be the issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == NULL, "Expected only one issuer\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); /* Adding a second issuer allows two issuers to be found - and the second * issuer is found before the first, implying certs are added to the head * of a list. */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert2); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags); ok(parent == cert2, "Expected cert2 to be the first issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == cert1, "Expected cert1 to be the second issuer\n"); parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags); ok(parent == NULL, "Expected no more than two issuers\n"); - ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError()); /* Self-sign a certificate, add to the store and test getting the issuer */ size = 0; - ok(CertStrToNameW(X509_ASN_ENCODING, certname, CERT_X500_NAME_STR, NULL, NULL, &size, NULL), + ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, NULL, &size, NULL), "CertStrToName should have worked\n"); - certencoded = HeapAlloc(GetProcessHeap(), 0, size); - ok(CertStrToNameW(X509_ASN_ENCODING, certname, CERT_X500_NAME_STR, NULL, certencoded, &size, NULL), + certencoded = malloc(size); + ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, certencoded, &size, NULL), "CertStrToName should have worked\n"); certsubject.pbData = certencoded; certsubject.cbData = size; cert3 = CertCreateSelfSignCertificate(0, &certsubject, 0, NULL, NULL, NULL, NULL, NULL); ok(cert3 != NULL, "CertCreateSelfSignCertificate should have worked\n"); ret = CertAddCertificateContextToStore(store, cert3, CERT_STORE_ADD_REPLACE_EXISTING, 0); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); CertFreeCertificateContext(cert3); cert3 = CertEnumCertificatesInStore(store, NULL); ok(cert3 != NULL, "CertEnumCertificatesInStore should have worked\n"); @@ -1728,16 +1677,17 @@ static void testGetIssuerCert(void) parent = CertGetIssuerCertificateFromStore(store, cert3, NULL, &flags); ok(!parent, "Expected NULL\n"); ok(GetLastError() == CRYPT_E_SELF_SIGNED, - "Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError()); + "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError()); CertFreeCertificateContext(child); CertFreeCertificateContext(cert1); CertFreeCertificateContext(cert2); + CertFreeCertificateContext(cert3); CertCloseStore(store, 0); - HeapFree(GetProcessHeap(), 0, certencoded); + free(certencoded); /* Test root storage self-signed certificate */ - store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, rootW); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"ROOT"); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); flags = 0; cert1 = CertEnumCertificatesInStore(store, NULL); ok(cert1 != NULL, "CertEnumCertificatesInStore should have worked\n"); @@ -1745,7 +1695,8 @@ static void testGetIssuerCert(void) parent = CertGetIssuerCertificateFromStore(store, cert1, NULL, &flags); ok(!parent, "Expected NULL\n"); ok(GetLastError() == CRYPT_E_SELF_SIGNED, - "Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError()); + "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError()); + CertFreeCertificateContext(cert1); CertCloseStore(store, 0); } @@ -1770,40 +1721,105 @@ static void testCryptHashCert(void) /* Test empty hash */ ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), NULL, &hashLen); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); - ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); + ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen); /* Test with empty buffer */ ret = CryptHashCertificate(0, 0, 0, NULL, 0, hash, &hashLen); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n"); /* Test a known value */ ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), hash, &hashLen); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n"); } +static void testCryptHashCert2(void) +{ +#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptHashCertificate2 (Vista+) + static const BYTE emptyHash[] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, + 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, + 0x09 }; + static const BYTE knownHash[] = { 0xae, 0x9d, 0xbf, 0x6d, 0xf5, 0x46, 0xee, + 0x8b, 0xc5, 0x7a, 0x13, 0xba, 0xc2, 0xb1, 0x04, 0xf2, 0xbf, 0x52, 0xa8, + 0xa2 }; + static const BYTE toHash[] = "abcdefghijklmnopqrstuvwxyz0123456789.,;!?:"; + BOOL ret; + BYTE hash[20]; + DWORD hashLen; + + /* Test empty hash */ + hashLen = sizeof(hash); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, NULL, 0, hash, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); + ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen); + ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n"); + + /* Test known hash */ + hashLen = sizeof(hash); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); + ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen); + ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n"); + + /* Test null hash size pointer just sets hash size */ + hashLen = 0; + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError()); + ok(hashLen == sizeof(hash), "Hash size not set correctly (%ld)\n", hashLen); + + /* Null algorithm ID crashes Windows implementations */ + if (0) { + /* Test null algorithm ID */ + hashLen = sizeof(hash); + ret = CryptHashCertificate2(NULL, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + } + + /* Test invalid algorithm */ + hashLen = sizeof(hash); + SetLastError(0xdeadbeef); + ret = CryptHashCertificate2(L"_SHOULDNOTEXIST_", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(!ret && GetLastError() == STATUS_NOT_FOUND, + "Expected STATUS_NOT_FOUND (0x%08lx), got 0x%08lx\n", STATUS_NOT_FOUND, GetLastError()); + + /* Test hash buffer too small */ + hashLen = sizeof(hash) / 2; + SetLastError(0xdeadbeef); + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA, + "Expected ERROR_MORE_DATA (%d), got %ld\n", ERROR_MORE_DATA, GetLastError()); + + /* Null hash length crashes Windows implementations */ + if (0) { + /* Test hashLen null with hash */ + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, NULL); + + /* Test hashLen null with no hash */ + ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, NULL); + } +#endif +} + static void verifySig(HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen, const BYTE *sig, unsigned int sigLen) { HCRYPTHASH hash; BOOL ret = CryptCreateHash(csp, CALG_SHA1, 0, 0, &hash); - ok(ret, "CryptCreateHash failed: %08x\n", GetLastError()); + ok(ret, "CryptCreateHash failed: %08lx\n", GetLastError()); if (ret) { BYTE mySig[64]; DWORD mySigSize = sizeof(mySig); ret = CryptHashData(hash, toSign, toSignLen, 0); - ok(ret, "CryptHashData failed: %08x\n", GetLastError()); - /* use the A variant so the test can run on Win9x */ + ok(ret, "CryptHashData failed: %08lx\n", GetLastError()); ret = CryptSignHashA(hash, AT_SIGNATURE, NULL, 0, mySig, &mySigSize); - ok(ret, "CryptSignHash failed: %08x\n", GetLastError()); + ok(ret, "CryptSignHash failed: %08lx\n", GetLastError()); if (ret) { - ok(mySigSize == sigLen, "Expected sig length %d, got %d\n", + ok(mySigSize == sigLen, "Expected sig length %d, got %ld\n", sigLen, mySigSize); ok(!memcmp(mySig, sig, sigLen), "Unexpected signature\n"); } @@ -1833,40 +1849,40 @@ static void testSignCert(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, NULL, &size); ok(!ret && GetLastError() == NTE_BAD_ALGID, - "Expected NTE_BAD_ALGID, got %08x\n", GetLastError()); + "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError()); algoID.pszObjId = (LPSTR)sigOID; ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, NULL, &size); ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID), - "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n", + "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n", GetLastError()); ret = CryptSignCertificate(0, AT_SIGNATURE, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, NULL, &size); ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID), - "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n", + "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n", GetLastError()); /* No keys exist in the new CSP yet.. */ ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, NULL, &size); ok(!ret && (GetLastError() == NTE_BAD_KEYSET || GetLastError() == - NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %08x\n", + NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %08lx\n", GetLastError()); ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key); - ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); + ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); if (ret) { ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, NULL, &size); - ok(ret, "CryptSignCertificate failed: %08x\n", GetLastError()); - ok(size <= *sigLen, "Expected size <= %d, got %d\n", *sigLen, size); + ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError()); + ok(size <= *sigLen, "Expected size <= %ld, got %ld\n", *sigLen, size); if (ret) { ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData, toBeSigned->cbData, &algoID, NULL, sig, &size); - ok(ret, "CryptSignCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError()); if (ret) { *sigLen = size; @@ -1886,22 +1902,16 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, DWORD size = 0; BOOL ret; - if (!pCryptEncodeObjectEx) - { - win_skip("no CryptEncodeObjectEx support\n"); - return; - } ret = CryptVerifyCertificateSignature(0, 0, NULL, 0, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptVerifyCertificateSignature(csp, 0, NULL, 0, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptVerifyCertificateSignature(csp, X509_ASN_ENCODING, NULL, 0, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); info.ToBeSigned.cbData = toBeSigned->cbData; info.ToBeSigned.pbData = toBeSigned->pbData; info.SignatureAlgorithm.pszObjId = (LPSTR)sigOID; @@ -1909,9 +1919,9 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, info.Signature.cbData = sigLen; info.Signature.pbData = (BYTE *)sig; info.Signature.cUnusedBits = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (cert) { PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL; @@ -1925,21 +1935,21 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, } CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, NULL, &pubKeySize); - pubKeyInfo = HeapAlloc(GetProcessHeap(), 0, pubKeySize); + pubKeyInfo = malloc(pubKeySize); if (pubKeyInfo) { ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo, &pubKeySize); - ok(ret, "CryptExportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptExportKey failed: %08lx\n", GetLastError()); if (ret) { ret = CryptVerifyCertificateSignature(csp, X509_ASN_ENCODING, cert, size, pubKeyInfo); - ok(ret, "CryptVerifyCertificateSignature failed: %08x\n", + ok(ret, "CryptVerifyCertificateSignature failed: %08lx\n", GetLastError()); } - HeapFree(GetProcessHeap(), 0, pubKeyInfo); + free(pubKeyInfo); } LocalFree(cert); } @@ -1953,28 +1963,18 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne DWORD size = 0; BOOL ret; - if (!pCryptVerifyCertificateSignatureEx) - { - win_skip("no CryptVerifyCertificateSignatureEx support\n"); - return; - } - if (!pCryptEncodeObjectEx) - { - win_skip("no CryptEncodeObjectEx support\n"); - return; - } - ret = pCryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL); + ret = CryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); + ret = CryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, 0, NULL, 0, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This crashes - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, NULL, 0, NULL, 0, NULL); */ info.ToBeSigned.cbData = toBeSigned->cbData; @@ -1984,61 +1984,59 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne info.Signature.cbData = sigLen; info.Signature.pbData = (BYTE *)sig; info.Signature.cUnusedBits = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (cert) { CRYPT_DATA_BLOB certBlob = { 0, NULL }; PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL; - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, - "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); certBlob.cbData = 1; certBlob.pbData = (void *)0xdeadbeef; - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == CRYPT_E_ASN1_EOD /* Win9x */ || - GetLastError() == CRYPT_E_ASN1_BADTAG /* Win98 */), - "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08x\n", + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); certBlob.cbData = size; certBlob.pbData = cert; - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This crashes - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, NULL, 0, NULL); */ CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, NULL, &size); - pubKeyInfo = HeapAlloc(GetProcessHeap(), 0, size); + pubKeyInfo = malloc(size); if (pubKeyInfo) { ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo, &size); - ok(ret, "CryptExportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptExportKey failed: %08lx\n", GetLastError()); if (ret) { - ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, + ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, pubKeyInfo, 0, NULL); - ok(ret, "CryptVerifyCertificateSignatureEx failed: %08x\n", + ok(ret, "CryptVerifyCertificateSignatureEx failed: %08lx\n", GetLastError()); } - HeapFree(GetProcessHeap(), 0, pubKeyInfo); + free(pubKeyInfo); } LocalFree(cert); } @@ -2046,6 +2044,43 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne static BYTE emptyCert[] = { 0x30, 0x00 }; + +/* Generated with: + * openssl ecparam -name prime256v1 -genkey -out private-key.pem + * openssl req -new -x509 -key private-key.pem -out certificate.der -outform der -days 900000 -subj "/C=US/ST=T/L=T/O=T/CN=T" + */ +static const BYTE self_signed_ecc_prime256v1[] = { +0x30,0x82,0x01,0xd1,0x30,0x82,0x01,0x77,0xa0,0x03,0x02,0x01,0x02,0x02,0x14,0x32, +0xc2,0xbe,0x7b,0xa2,0x85,0x78,0x89,0x82,0xf8,0x10,0x66,0xd4,0x1d,0xd4,0x97,0x61, +0x83,0x02,0xc8,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x30, +0x3d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0a, +0x30,0x08,0x06,0x03,0x55,0x04,0x08,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03, +0x55,0x04,0x07,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x0a,0x0c, +0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x0c,0x01,0x54,0x30,0x20, +0x17,0x0d,0x32,0x33,0x30,0x36,0x32,0x39,0x30,0x32,0x32,0x34,0x30,0x33,0x5a,0x18, +0x0f,0x34,0x34,0x38,0x37,0x30,0x38,0x31,0x30,0x30,0x32,0x32,0x34,0x30,0x33,0x5a, +0x30,0x3d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31, +0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x08,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06, +0x03,0x55,0x04,0x07,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x0a, +0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x0c,0x01,0x54,0x30, +0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a,0x86, +0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xfe,0xdb,0x26,0x60,0xf6,0x89, +0x3d,0xa4,0x50,0x1f,0x06,0x91,0x4e,0x07,0x86,0x70,0x2b,0xc0,0x7c,0x5e,0xb3,0xca, +0xdc,0x1a,0x8b,0x82,0xdd,0x41,0x8a,0x62,0x0f,0xba,0xd1,0xd7,0x80,0xc8,0x20,0x77, +0xba,0xe7,0xe1,0x36,0xf8,0x76,0x9a,0x54,0x6a,0x1b,0x67,0x45,0x3b,0xd7,0x85,0x84, +0xbe,0x11,0xe6,0x6c,0x70,0xd8,0x18,0x68,0xd8,0xa7,0xa3,0x53,0x30,0x51,0x30,0x1d, +0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x94,0x15,0x14,0xad,0x7e,0xaf,0x63, +0xa4,0x12,0x29,0xaa,0xe4,0x26,0x54,0x7b,0x4e,0x2c,0xb9,0xdb,0xc8,0x30,0x1f,0x06, +0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x94,0x15,0x14,0xad,0x7e,0xaf, +0x63,0xa4,0x12,0x29,0xaa,0xe4,0x26,0x54,0x7b,0x4e,0x2c,0xb9,0xdb,0xc8,0x30,0x0f, +0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30, +0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x03,0x48,0x00,0x30,0x45, +0x02,0x21,0x00,0x83,0xae,0xa2,0x23,0x95,0x1a,0x65,0x09,0x48,0x40,0x10,0xeb,0x94, +0x90,0x02,0xde,0xe3,0x0f,0x4b,0xd1,0x23,0x73,0xc6,0xd5,0x49,0xa8,0x9c,0x06,0x9c, +0xd3,0xfb,0xc1,0x02,0x20,0x0c,0xf3,0x92,0xec,0xc8,0xb5,0x7e,0x9c,0x14,0x5d,0xb0, +0x26,0xfd,0x2a,0x3c,0x4e,0x08,0x55,0x09,0x35,0x40,0x7c,0xf8,0xf9,0x1b,0x22,0x55, +0x08,0x9b,0x3f,0x37,0x29, }; + static void testCertSigs(void) { HCRYPTPROV csp; @@ -2053,22 +2088,30 @@ static void testCertSigs(void) BOOL ret; BYTE sig[64]; DWORD sigSize = sizeof(sig); + PCCERT_CONTEXT cert; /* Just in case a previous run failed, delete this thing */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); testSignCert(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, &sigSize); testVerifyCertSig(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize); testVerifyCertSigEx(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize); CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); + + cert = CertCreateCertificateContext(X509_ASN_ENCODING, self_signed_ecc_prime256v1, sizeof(self_signed_ecc_prime256v1)); + ok(!!cert, "failed, error %#lx.\n", GetLastError()); + ret = CryptVerifyCertificateSignature(0, X509_ASN_ENCODING, self_signed_ecc_prime256v1, + sizeof(self_signed_ecc_prime256v1), &cert->pCertInfo->SubjectPublicKeyInfo); + ok(ret, "failed, error %#lx.\n", GetLastError()); + CertFreeCertificateContext(cert); } static const BYTE md5SignedEmptyCert[] = { @@ -2104,41 +2147,33 @@ static void testSignAndEncodeCert(void) ret = CryptSignAndEncodeCertificate(0, 0, 0, NULL, NULL, &algID, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, NULL, NULL, &algID, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptSignAndEncodeCertificate(0, 0, 0, X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - /* Crashes on some win9x boxes */ - if (0) - { - ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, - X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, + X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Crashes ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, NULL, NULL, NULL, &size); */ ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size); - ok(!ret && - (GetLastError() == NTE_BAD_ALGID || - GetLastError() == OSS_BAD_PTR), /* win9x */ - "Expected NTE_BAD_ALGID, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == NTE_BAD_ALGID, + "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError()); algID.pszObjId = oid_rsa_md5rsa; ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size); - ok(!ret && - (GetLastError() == ERROR_INVALID_PARAMETER || - GetLastError() == NTE_BAD_ALGID || - GetLastError() == OSS_BAD_PTR), /* Win9x */ - "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n", + ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID), + "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n", GetLastError()); algID.pszObjId = oid_rsa_md5; ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, @@ -2146,20 +2181,20 @@ static void testSignAndEncodeCert(void) /* oid_rsa_md5 not present in some win2k */ if (ret) { - LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size); + LPBYTE buf = malloc(size); if (buf) { ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, buf, &size); - ok(ret, "CryptSignAndEncodeCertificate failed: %08x\n", + ok(ret, "CryptSignAndEncodeCertificate failed: %08lx\n", GetLastError()); /* Tricky: because the NULL parameters may either be omitted or * included as an asn.1-encoded NULL (0x05,0x00), two different * values are allowed. */ ok(size == sizeof(md5SignedEmptyCert) || - size == sizeof(md5SignedEmptyCertNoNull), "Unexpected size %d\n", + size == sizeof(md5SignedEmptyCertNoNull), "Unexpected size %ld\n", size); if (size == sizeof(md5SignedEmptyCert)) ok(!memcmp(buf, md5SignedEmptyCert, size), @@ -2167,7 +2202,7 @@ static void testSignAndEncodeCert(void) else if (size == sizeof(md5SignedEmptyCertNoNull)) ok(!memcmp(buf, md5SignedEmptyCertNoNull, size), "Unexpected value\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } } } @@ -2179,42 +2214,63 @@ static void testCreateSelfSignCert(void) HCRYPTPROV csp; BOOL ret; HCRYPTKEY key; - CRYPT_KEY_PROV_INFO info; - - if (!pCertCreateSelfSignCertificate) - { - win_skip("CertCreateSelfSignCertificate() is not available\n"); - return; - } + CRYPT_KEY_PROV_INFO info, *ret_info; + DWORD size; /* This crashes: - context = pCertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, - NULL); - * Calling this with no first parameter creates a new key container, which - * lasts beyond the test, so I don't test that. Nb: the generated key - * name is a GUID. - context = pCertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, - NULL); - */ + context = CertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, NULL); */ + + /* Test CSP created by implementation without CSP or CSP parameters provided. */ + context = CertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, NULL); + ok(!!context, "failed, error %#lx.\n", GetLastError()); + size = 0; + ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size); + ok(ret, "failed, error %#lx.\n", GetLastError()); + ret_info = malloc(size); + ok(!!ret_info, "memory allocation failed.\n"); + ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, ret_info, &size); + ok(ret, "failed, error %#lx.\n", GetLastError()); + CertFreeCertificateContext(context); + ok(ret_info->dwKeySpec == AT_SIGNATURE, "got %#lx.\n", ret_info->dwKeySpec); + ok(!ret_info->dwFlags, "got %#lx.\n", ret_info->dwFlags); + ok(ret_info->pwszContainerName && *ret_info->pwszContainerName, "got %s.\n", + debugstr_w(ret_info->pwszContainerName)); + ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName, ret_info->dwProvType, 0); + ok(ret, "failed, error %#lx.\n", GetLastError()); + ret = CryptGetUserKey(csp, AT_SIGNATURE, &key); + ok(ret, "failed, error %#lx.\n", GetLastError()); + ret = CryptDestroyKey(key); + ok(ret, "failed, error %#lx.\n", GetLastError()); + ret = CryptGetUserKey(csp, AT_KEYEXCHANGE, &key); + ok(!ret && GetLastError() == NTE_NO_KEY, "got ret %d, error %#lx.\n", ret, GetLastError()); + CryptReleaseContext(csp, 0); + csp = 0xdeadbeef; + ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName, + ret_info->dwProvType, CRYPT_DELETEKEYSET); + ok(ret, "failed, error %#lx.\n", GetLastError()); + ok(!csp, "got %p.\n", (void *)csp); + ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName, ret_info->dwProvType, 0); + ok(!ret && GetLastError() == NTE_BAD_KEYSET, "got ret %d, error %#lx.\n", ret, GetLastError()); + free(ret_info); /* Acquire a CSP */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); - context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(!context && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key); - ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); + ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); if (ret) { - context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); - ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n", + ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); if (context) { @@ -2226,25 +2282,25 @@ static void testCreateSelfSignCert(void) ok(ret && size, "Expected non-zero key provider info\n"); if (size) { - PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size); + PCRYPT_KEY_PROV_INFO pInfo = malloc(size); if (pInfo) { ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); ok(pInfo->dwKeySpec == AT_SIGNATURE, - "Expected AT_SIGNATURE, got %d\n", pInfo->dwKeySpec); + "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec); } - HeapFree(GetProcessHeap(), 0, pInfo); + free(pInfo); } } @@ -2255,41 +2311,41 @@ static void testCreateSelfSignCert(void) } CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); /* Do the same test with a CSP, AT_KEYEXCHANGE and key info */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key); - ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); + ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); memset(&info,0,sizeof(info)); info.dwProvType = PROV_RSA_FULL; info.dwKeySpec = AT_KEYEXCHANGE; info.pwszProvName = (LPWSTR) MS_DEF_PROV_W; - info.pwszContainerName = cspNameW; + info.pwszContainerName = (WCHAR *)L"WineCryptTemp"; /* This should fail because the CSP doesn't have the specified key. */ SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context == NULL, "expected failure\n"); if (context != NULL) CertFreeCertificateContext(context); else - ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08x\n", + ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n", GetLastError()); /* Again, with a CSP, AT_SIGNATURE and key info */ info.dwKeySpec = AT_SIGNATURE; SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, - "CertCreateSelfSignCertificate failed: %08x\n", GetLastError()); + "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); if (context) { DWORD size = 0; @@ -2300,25 +2356,25 @@ static void testCreateSelfSignCert(void) ok(ret && size, "Expected non-zero key provider info\n"); if (size) { - PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size); + PCRYPT_KEY_PROV_INFO pInfo = malloc(size); if (pInfo) { ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); ok(pInfo->dwKeySpec == AT_SIGNATURE, - "Expected AT_SIGNATURE, got %d\n", pInfo->dwKeySpec); + "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec); } - HeapFree(GetProcessHeap(), 0, pInfo); + free(pInfo); } } @@ -2327,15 +2383,15 @@ static void testCreateSelfSignCert(void) CryptDestroyKey(key); CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); /* Do the same test with no CSP, AT_KEYEXCHANGE and key info */ info.dwKeySpec = AT_KEYEXCHANGE; - context = pCertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, NULL, NULL); - ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n", + ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); if (context) { @@ -2347,73 +2403,73 @@ static void testCreateSelfSignCert(void) ok(ret && size, "Expected non-zero key provider info\n"); if (size) { - PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size); + PCRYPT_KEY_PROV_INFO pInfo = malloc(size); if (pInfo) { ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); ok(pInfo->dwKeySpec == AT_KEYEXCHANGE, - "Expected AT_KEYEXCHANGE, got %d\n", pInfo->dwKeySpec); + "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec); } - HeapFree(GetProcessHeap(), 0, pInfo); + free(pInfo); } } CertFreeCertificateContext(context); } - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); /* Acquire a CSP and generate an AT_KEYEXCHANGE key in it. */ - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); - context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(!context && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); ret = CryptGenKey(csp, AT_KEYEXCHANGE, 0, &key); - ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); + ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); CryptDestroyKey(key); memset(&info,0,sizeof(info)); info.dwProvType = PROV_RSA_FULL; info.dwKeySpec = AT_SIGNATURE; info.pwszProvName = (LPWSTR) MS_DEF_PROV_W; - info.pwszContainerName = cspNameW; + info.pwszContainerName = (WCHAR *)L"WineCryptTemp"; /* This should fail because the CSP doesn't have the specified key. */ SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context == NULL, "expected failure\n"); if (context != NULL) CertFreeCertificateContext(context); else - ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08x\n", + ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n", GetLastError()); /* Again, with a CSP, AT_KEYEXCHANGE and key info. This succeeds because the * CSP has an AT_KEYEXCHANGE key in it. */ info.dwKeySpec = AT_KEYEXCHANGE; SetLastError(0xdeadbeef); - context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, + context = CertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, - "CertCreateSelfSignCertificate failed: %08x\n", GetLastError()); + "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError()); if (context) { DWORD size = 0; @@ -2424,25 +2480,25 @@ static void testCreateSelfSignCert(void) ok(ret && size, "Expected non-zero key provider info\n"); if (size) { - PCRYPT_KEY_PROV_INFO pInfo = HeapAlloc(GetProcessHeap(), 0, size); + PCRYPT_KEY_PROV_INFO pInfo = malloc(size); if (pInfo) { ret = CertGetCertificateContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); if (ret) { /* Sanity-check the key provider */ - ok(!lstrcmpW(pInfo->pwszContainerName, cspNameW), + ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"), "Unexpected key container\n"); ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W), "Unexpected provider\n"); ok(pInfo->dwKeySpec == AT_KEYEXCHANGE, - "Expected AT_KEYEXCHANGE, got %d\n", pInfo->dwKeySpec); + "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec); } - HeapFree(GetProcessHeap(), 0, pInfo); + free(pInfo); } } @@ -2450,9 +2506,9 @@ static void testCreateSelfSignCert(void) } CryptReleaseContext(csp, 0); - ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); - ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); } @@ -2492,7 +2548,7 @@ static void testIntendedKeyUsage(void) /* The unused bytes are filled with 0. */ ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes, sizeof(usage_bytes)); - ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError()); ok(!memcmp(usage_bytes, expected_usage1, sizeof(expected_usage1)), "unexpected value\n"); /* The usage bytes are copied in big-endian order. */ @@ -2500,7 +2556,7 @@ static void testIntendedKeyUsage(void) ext.Value.pbData = usage2; ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes, sizeof(usage_bytes)); - ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError()); ok(!memcmp(usage_bytes, expected_usage2, sizeof(expected_usage2)), "unexpected value\n"); } @@ -2517,15 +2573,15 @@ static void testKeyUsage(void) /* Test base cases */ ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); size = 1; ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); size = 0; ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); /* These crash ret = CertSetEnhancedKeyUsage(NULL, NULL); usage.cUsageIdentifier = 0; @@ -2534,7 +2590,7 @@ static void testKeyUsage(void) /* Test with a cert with no enhanced key usage extension */ context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); if (context) { @@ -2544,7 +2600,7 @@ static void testKeyUsage(void) ret = CertGetEnhancedKeyUsage(context, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); size = 1; ret = CertGetEnhancedKeyUsage(context, 0, NULL, &size); if (ret) @@ -2554,11 +2610,11 @@ static void testKeyUsage(void) * usage set for this cert (which implies it's valid for all uses.) */ ok(GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); - ok(size == sizeof(CERT_ENHKEY_USAGE), "Wrong size %d\n", size); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); + ok(size == sizeof(CERT_ENHKEY_USAGE), "Wrong size %ld\n", size); ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n", + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n", pUsage->cUsageIdentifier); } else @@ -2567,18 +2623,18 @@ static void testKeyUsage(void) * CRYPT_E_NOT_FOUND. */ ok(GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); } /* I can add a usage identifier when no key usage has been set */ ret = CertAddEnhancedKeyUsageIdentifier(context, oid); - ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n", + ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n", GetLastError()); size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n", pUsage->cUsageIdentifier); if (pUsage->cUsageIdentifier) ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid), @@ -2586,35 +2642,35 @@ static void testKeyUsage(void) /* Now set an empty key usage */ pUsage->cUsageIdentifier = 0; ret = CertSetEnhancedKeyUsage(context, pUsage); - ok(ret, "CertSetEnhancedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError()); /* Shouldn't find it in the cert */ size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Should find it as an extended property */ ret = CertGetEnhancedKeyUsage(context, CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n", pUsage->cUsageIdentifier); /* Should find it as either */ ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n", pUsage->cUsageIdentifier); /* Add a usage identifier */ ret = CertAddEnhancedKeyUsageIdentifier(context, oid); - ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n", + ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n", GetLastError()); size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 1, "Expected 1 identifier, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 1, "Expected 1 identifier, got %ld\n", pUsage->cUsageIdentifier); if (pUsage->cUsageIdentifier) ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid), @@ -2623,14 +2679,14 @@ static void testKeyUsage(void) * a duplicate usage identifier on versions prior to Vista */ ret = CertAddEnhancedKeyUsageIdentifier(context, oid); - ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n", + ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n", GetLastError()); size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); ok(pUsage->cUsageIdentifier == 1 || pUsage->cUsageIdentifier == 2, - "Expected 1 or 2 identifiers, got %d\n", pUsage->cUsageIdentifier); + "Expected 1 or 2 identifiers, got %ld\n", pUsage->cUsageIdentifier); if (pUsage->cUsageIdentifier) ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid), "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[0]); @@ -2639,21 +2695,20 @@ static void testKeyUsage(void) "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[1]); /* Now set a NULL extended property--this deletes the property. */ ret = CertSetEnhancedKeyUsage(context, NULL); - ok(ret, "CertSetEnhancedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError()); SetLastError(0xbaadcafe); size = sizeof(buf); ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); - ok(ret || broken(!ret && GetLastError() == CRYPT_E_NOT_FOUND /* NT4 */), - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); ok(GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); CertFreeCertificateContext(context); } /* Now test with a cert with an enhanced key usage extension */ context = CertCreateCertificateContext(X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); if (context) { @@ -2665,8 +2720,8 @@ static void testKeyUsage(void) */ ret = CertGetEnhancedKeyUsage(context, CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufSize); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + buf = malloc(bufSize); if (buf) { PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf; @@ -2676,18 +2731,18 @@ static void testKeyUsage(void) ret = CertGetEnhancedKeyUsage(context, CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size); ok(ret && GetLastError() == 0, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n", pUsage->cUsageIdentifier); for (i = 0; i < pUsage->cUsageIdentifier; i++) ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected %s, got %s\n", keyUsages[i], pUsage->rgpszUsageIdentifier[i]); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufSize); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + buf = malloc(bufSize); if (buf) { PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf; @@ -2700,27 +2755,27 @@ static void testKeyUsage(void) * count is positive. I don't enforce that here. */ ok(ret, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n", pUsage->cUsageIdentifier); for (i = 0; i < pUsage->cUsageIdentifier; i++) ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected %s, got %s\n", keyUsages[i], pUsage->rgpszUsageIdentifier[i]); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* Shouldn't find it as an extended property */ ret = CertGetEnhancedKeyUsage(context, CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Adding a usage identifier overrides the cert's usage!? */ ret = CertAddEnhancedKeyUsageIdentifier(context, szOID_RSA_RSA); - ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n", + ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n", GetLastError()); ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufSize); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + buf = malloc(bufSize); if (buf) { PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf; @@ -2729,19 +2784,19 @@ static void testKeyUsage(void) size = bufSize; ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); ok(ret, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n", pUsage->cUsageIdentifier); ok(!strcmp(pUsage->rgpszUsageIdentifier[0], szOID_RSA_RSA), "Expected %s, got %s\n", szOID_RSA_RSA, pUsage->rgpszUsageIdentifier[0]); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* But querying the cert directly returns its usage */ ret = CertGetEnhancedKeyUsage(context, CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufSize); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + buf = malloc(bufSize); if (buf) { PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf; @@ -2750,23 +2805,23 @@ static void testKeyUsage(void) ret = CertGetEnhancedKeyUsage(context, CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size); ok(ret, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n", pUsage->cUsageIdentifier); for (i = 0; i < pUsage->cUsageIdentifier; i++) ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected %s, got %s\n", keyUsages[i], pUsage->rgpszUsageIdentifier[i]); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* And removing the only usage identifier in the extended property * results in the cert's key usage being found. */ ret = CertRemoveEnhancedKeyUsageIdentifier(context, szOID_RSA_RSA); - ok(ret, "CertRemoveEnhancedKeyUsage failed: %08x\n", GetLastError()); + ok(ret, "CertRemoveEnhancedKeyUsage failed: %08lx\n", GetLastError()); ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize); - ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, bufSize); + ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + buf = malloc(bufSize); if (buf) { PCERT_ENHKEY_USAGE pUsage = (PCERT_ENHKEY_USAGE)buf; @@ -2775,14 +2830,14 @@ static void testKeyUsage(void) size = bufSize; ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size); ok(ret, - "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError()); - ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n", + "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError()); + ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n", pUsage->cUsageIdentifier); for (i = 0; i < pUsage->cUsageIdentifier; i++) ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected %s, got %s\n", keyUsages[i], pUsage->rgpszUsageIdentifier[i]); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } CertFreeCertificateContext(context); @@ -2818,117 +2873,111 @@ static void testGetValidUsages(void) LPSTR *oids = NULL; PCCERT_CONTEXT contexts[3]; - if (!pCertGetValidUsages) - { - win_skip("CertGetValidUsages() is not available\n"); - return; - } - /* Crash - ret = pCertGetValidUsages(0, NULL, NULL, NULL, NULL); - ret = pCertGetValidUsages(0, NULL, NULL, NULL, &size); + ret = CertGetValidUsages(0, NULL, NULL, NULL, NULL); + ret = CertGetValidUsages(0, NULL, NULL, NULL, &size); */ contexts[0] = NULL; - numOIDs = size = 0xdeadbeef; + size = numOIDs = 0xdeadbeef; SetLastError(0xdeadbeef); - ret = pCertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %d\n", GetLastError()); + ret = CertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %ld\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); - ok(size == 0, "Expected size 0, got %d\n", size); + ok(size == 0, "Expected size 0, got %ld\n", size); contexts[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); contexts[1] = CertCreateCertificateContext(X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage)); contexts[2] = CertCreateCertificateContext(X509_ASN_ENCODING, cert2WithUsage, sizeof(cert2WithUsage)); - numOIDs = size = 0xdeadbeef; - ret = pCertGetValidUsages(0, NULL, &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + size = numOIDs = 0xdeadbeef; + ret = CertGetValidUsages(0, NULL, &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); - ok(size == 0, "Expected size 0, got %d\n", size); - numOIDs = size = 0xdeadbeef; - ret = pCertGetValidUsages(1, contexts, &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ok(size == 0, "Expected size 0, got %ld\n", size); + size = numOIDs = 0xdeadbeef; + ret = CertGetValidUsages(1, contexts, &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); - ok(size == 0, "Expected size 0, got %d\n", size); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ok(size == 0, "Expected size 0, got %ld\n", size); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); - oids = HeapAlloc(GetProcessHeap(), 0, size); + oids = malloc(size); if (oids) { int i; DWORD smallSize = 1; SetLastError(0xdeadbeef); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); ok(!ret && GetLastError() == ERROR_MORE_DATA, - "Expected ERROR_MORE_DATA, got %d\n", GetLastError()); - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + "Expected ERROR_MORE_DATA, got %ld\n", GetLastError()); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", oids[i]); - HeapFree(GetProcessHeap(), 0, oids); + free(oids); } numOIDs = 0xdeadbeef; /* Oddly enough, this crashes when the number of contexts is not 1: - ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); * but setting size to 0 allows it to succeed: */ size = 0; - ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); - oids = HeapAlloc(GetProcessHeap(), 0, size); + oids = malloc(size); if (oids) { int i; - ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", oids[i]); - HeapFree(GetProcessHeap(), 0, oids); + free(oids); } numOIDs = 0xdeadbeef; size = 0; - ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); - oids = HeapAlloc(GetProcessHeap(), 0, size); + oids = malloc(size); if (oids) { int i; - ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", oids[i]); - HeapFree(GetProcessHeap(), 0, oids); + free(oids); } numOIDs = 0xdeadbeef; size = 0; - ret = pCertGetValidUsages(3, contexts, &numOIDs, NULL, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(3, contexts, &numOIDs, NULL, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); - oids = HeapAlloc(GetProcessHeap(), 0, size); + oids = malloc(size); if (oids) { int i; - ret = pCertGetValidUsages(3, contexts, &numOIDs, oids, &size); - ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); + ret = CertGetValidUsages(3, contexts, &numOIDs, oids, &size); + ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", oids[i]); - HeapFree(GetProcessHeap(), 0, oids); + free(oids); } CertFreeCertificateContext(contexts[0]); CertFreeCertificateContext(contexts[1]); @@ -2973,12 +3022,12 @@ static void testCompareCertName(void) blob1.pbData = emptyCert; blob1.cbData = sizeof(emptyCert); ret = CertCompareCertificateName(0, &blob1, &blob1); - ok(ret, "CertCompareCertificateName failed: %08x\n", GetLastError()); + ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError()); /* It doesn't have to be a valid encoded name.. */ blob1.pbData = bogus; blob1.cbData = sizeof(bogus); ret = CertCompareCertificateName(0, &blob1, &blob1); - ok(ret, "CertCompareCertificateName failed: %08x\n", GetLastError()); + ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError()); /* Leading zeroes matter.. */ blob2.pbData = bogusPrime; blob2.cbData = sizeof(bogusPrime); @@ -3038,7 +3087,7 @@ static void testIsRDNAttrsInCertificateName(void) static char juan_with_intermediate_space[] = "Juan Lang"; static char juan_with_trailing_space[] = "Juan Lang "; static char juan_lower_case[] = "juan lang"; - static WCHAR juanW[] = { 'J','u','a','n',' ','L','a','n','g',0 }; + static WCHAR juanW[] = L"Juan Lang"; static char the_wine_project[] = "The Wine Project"; BOOL ret; CERT_NAME_BLOB name; @@ -3056,41 +3105,41 @@ static void testIsRDNAttrsInCertificateName(void) SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(0, 0, &name, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); - ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError()); + ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError()); attr[0].pszObjId = oid_1_2_3; rdn.rgRDNAttr = attr; rdn.cRDNAttr = 1; SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); attr[0].pszObjId = oid_common_name; attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING; attr[0].Value.cbData = strlen(juan); attr[0].Value.pbData = (BYTE *)juan; ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); - ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError()); + ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError()); /* Again, spaces are not removed for name comparison. */ attr[0].Value.cbData = strlen(juan_with_leading_space); attr[0].Value.pbData = (BYTE *)juan_with_leading_space; SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); attr[0].Value.cbData = strlen(juan_with_intermediate_space); attr[0].Value.pbData = (BYTE *)juan_with_intermediate_space; SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); attr[0].Value.cbData = strlen(juan_with_trailing_space); attr[0].Value.pbData = (BYTE *)juan_with_trailing_space; SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); /* The lower case name isn't matched unless a case insensitive match is * specified. */ @@ -3099,12 +3148,12 @@ static void testIsRDNAttrsInCertificateName(void) SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG, &name, &rdn); ok(ret || broken(!ret && GetLastError() == CRYPT_E_NO_MATCH), /* Older crypt32 */ - "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError()); + "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError()); /* The values don't match unless they have the same RDN type */ attr[0].dwValueType = CERT_RDN_UNICODE_STRING; attr[0].Value.cbData = lstrlenW(juanW) * sizeof(WCHAR); @@ -3112,19 +3161,19 @@ static void testIsRDNAttrsInCertificateName(void) SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, CERT_UNICODE_IS_RDN_ATTRS_FLAG, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); attr[0].dwValueType = CERT_RDN_IA5_STRING; attr[0].Value.cbData = strlen(juan); attr[0].Value.pbData = (BYTE *)juan; SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); /* All attributes must be present */ attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING; attr[0].Value.cbData = strlen(juan); @@ -3137,18 +3186,18 @@ static void testIsRDNAttrsInCertificateName(void) SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); /* Order also matters */ name.pbData = cnThenO; name.cbData = sizeof(cnThenO); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); - ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError()); + ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError()); name.pbData = oThenCN; name.cbData = sizeof(oThenCN); SetLastError(0xdeadbeef); ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); } static BYTE int1[] = { 0x88, 0xff, 0xff, 0xff }; @@ -3181,7 +3230,7 @@ static void testCompareIntegerBlob(void) { ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2); ok(ret == intBlobs[i].areEqual, - "%d: expected blobs %s compare\n", i, intBlobs[i].areEqual ? + "%ld: expected blobs %s compare\n", i, intBlobs[i].areEqual ? "to" : "not to"); } } @@ -3208,23 +3257,23 @@ static void testComparePublicKeyInfo(void) */ /* Empty public keys compare */ ret = CertComparePublicKeyInfo(0, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); /* Different OIDs appear to compare */ info1.Algorithm.pszObjId = oid_rsa_rsa; info2.Algorithm.pszObjId = oid_rsa_sha1rsa; ret = CertComparePublicKeyInfo(0, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); info2.Algorithm.pszObjId = oid_x957_dsa; ret = CertComparePublicKeyInfo(0, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); info1.PublicKey.cbData = sizeof(bits1); info1.PublicKey.pbData = bits1; @@ -3233,9 +3282,9 @@ static void testComparePublicKeyInfo(void) info2.PublicKey.pbData = bits1; info2.PublicKey.cUnusedBits = 0; ret = CertComparePublicKeyInfo(0, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2); - ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError()); info2.Algorithm.pszObjId = oid_rsa_rsa; info1.PublicKey.cbData = sizeof(bits4); @@ -3331,21 +3380,19 @@ static void testHashPublicKeyInfo(void) */ ret = CryptHashPublicKeyInfo(0, 0, 0, 0, NULL, NULL, &len); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - /* Crashes on some win9x boxes */ - if (0) + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + + if (0) /* crash */ { ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, NULL, NULL, &len); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); } ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, NULL, &len); - ok(ret || - broken(!ret), /* win9x */ - "CryptHashPublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError()); if (ret) { - ok(len == 16, "Expected hash size 16, got %d\n", len); + ok(len == 16, "Expected hash size 16, got %ld\n", len); if (len == 16) { static const BYTE emptyHash[] = { 0xb8,0x51,0x3a,0x31,0x0e,0x9f,0x40, @@ -3354,7 +3401,7 @@ static void testHashPublicKeyInfo(void) ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, buf, &len); - ok(ret, "CryptHashPublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError()); ok(!memcmp(buf, emptyHash, len), "Unexpected hash\n"); } } @@ -3377,45 +3424,35 @@ static void testHashToBeSigned(void) SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, NULL, 0, NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Can't sign anything: has to be asn.1 encoded, at least */ SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, int1, sizeof(int1), NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_MORE_INPUT), /* win9x */ - "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); /* Can't be empty, either */ SetLastError(0xdeadbeef); ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, emptyCert, sizeof(emptyCert), NULL, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Signing a cert works */ ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert, sizeof(md5SignedEmptyCert), NULL, &size); - ok(ret || - broken(!ret), /* win9x */ - "CryptHashToBeSigned failed: %08x\n", GetLastError()); + ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %d\n", size); + ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %ld\n", size); } ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert, sizeof(md5SignedEmptyCert), hash, &size); - ok(ret || broken(!ret && GetLastError() == NTE_BAD_ALGID) /* NT4 */, - "CryptHashToBeSigned failed: %08x\n", GetLastError()); - + ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError()); ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n"); } @@ -3463,45 +3500,45 @@ static void testVerifySubjectCert(void) */ flags = 0; ret = CertVerifySubjectCertificateContext(NULL, NULL, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); flags = CERT_STORE_NO_CRL_FLAG; ret = CertVerifySubjectCertificateContext(NULL, NULL, &flags); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); flags = 0; context1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ret = CertVerifySubjectCertificateContext(NULL, context1, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); ret = CertVerifySubjectCertificateContext(context1, NULL, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); ret = CertVerifySubjectCertificateContext(context1, context1, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); context2 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCertWithDifferentSubject, sizeof(bigCertWithDifferentSubject)); SetLastError(0xdeadbeef); ret = CertVerifySubjectCertificateContext(context1, context2, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); flags = CERT_STORE_REVOCATION_FLAG; ret = CertVerifySubjectCertificateContext(context1, context2, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); ok(flags == (CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG), - "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08x\n", + "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n", flags); flags = CERT_STORE_SIGNATURE_FLAG; ret = CertVerifySubjectCertificateContext(context1, context2, &flags); - ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n", + ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n", GetLastError()); ok(flags == CERT_STORE_SIGNATURE_FLAG, - "Expected CERT_STORE_SIGNATURE_FLAG, got %08x\n", flags); + "Expected CERT_STORE_SIGNATURE_FLAG, got %08lx\n", flags); CertFreeCertificateContext(context2); CertFreeCertificateContext(context1); @@ -3594,6 +3631,260 @@ static const BYTE rootSignedCRL[] = { 0xd5,0xbc,0xb0,0xd5,0xa5,0x9c,0x1b,0x72,0xc3,0x0f,0xa3,0xe3,0x3c,0xf0,0xc3, 0x91,0xe8,0x93,0x4f,0xd4,0x2f }; +static const BYTE ocsp_cert[] = { + 0x30, 0x82, 0x06, 0xcd, 0x30, 0x82, 0x05, 0xb5, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x10, 0x08, 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, + 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, 0xb1, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x4f, + 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, + 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0c, + 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, + 0x31, 0x29, 0x30, 0x27, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x20, 0x44, + 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x54, 0x4c, 0x53, 0x20, + 0x52, 0x53, 0x41, 0x20, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x32, + 0x30, 0x32, 0x30, 0x20, 0x43, 0x41, 0x31, 0x30, 0x1e, 0x17, 0x0d, 0x32, + 0x31, 0x30, 0x34, 0x32, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, + 0x17, 0x0d, 0x32, 0x32, 0x30, 0x35, 0x32, 0x39, 0x32, 0x33, 0x35, 0x39, + 0x35, 0x39, 0x5a, 0x30, 0x6b, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, + 0x55, 0x04, 0x08, 0x13, 0x0a, 0x57, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, + 0x74, 0x6f, 0x6e, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, + 0x13, 0x08, 0x42, 0x65, 0x6c, 0x6c, 0x65, 0x76, 0x75, 0x65, 0x31, 0x14, + 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x56, 0x61, 0x6c, + 0x76, 0x65, 0x20, 0x43, 0x6f, 0x72, 0x70, 0x2e, 0x31, 0x1e, 0x30, 0x1c, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, + 0x73, 0x74, 0x65, 0x61, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, + 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, + 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xcd, 0x98, 0x0c, 0x13, 0xb2, 0xb9, 0xf2, 0xa5, 0xc6, 0x52, 0xad, + 0xf9, 0x4d, 0xcf, 0x1e, 0x2b, 0x74, 0x05, 0xd1, 0x2e, 0x95, 0xc3, 0x9d, + 0x9b, 0x03, 0x2a, 0xc6, 0x65, 0x1e, 0xda, 0x5d, 0x57, 0x3c, 0x61, 0xa1, + 0x3d, 0xa3, 0xe7, 0x0c, 0xdd, 0xb1, 0x6b, 0x30, 0x97, 0x99, 0xc7, 0x77, + 0xab, 0xc2, 0xb0, 0x0a, 0x5b, 0x1c, 0x86, 0x55, 0x42, 0x25, 0xa8, 0x4e, + 0xe2, 0x61, 0xfe, 0x88, 0x10, 0x25, 0xf5, 0x8e, 0x9c, 0x0f, 0xc7, 0xa5, + 0xef, 0x9d, 0xd5, 0xf0, 0x2a, 0xf2, 0x31, 0x59, 0x59, 0xfc, 0xe0, 0x1f, + 0x8f, 0xb4, 0xa1, 0x06, 0x32, 0x04, 0x37, 0x3d, 0x9d, 0xad, 0xc1, 0xe0, + 0x00, 0x3d, 0x8d, 0x60, 0x4c, 0x9e, 0x6a, 0x1f, 0xd2, 0xf6, 0xf8, 0x86, + 0x0b, 0x11, 0x7b, 0xfd, 0x75, 0xae, 0x20, 0x9b, 0xca, 0x52, 0x5f, 0x4e, + 0xad, 0x2e, 0xa2, 0xce, 0xed, 0x35, 0x08, 0x23, 0xa8, 0x6e, 0x61, 0x7e, + 0x18, 0x1a, 0x6a, 0xd9, 0xe0, 0x3b, 0x52, 0x64, 0xe9, 0x2c, 0x81, 0x8f, + 0xbc, 0x4b, 0x48, 0xd1, 0x7a, 0x3e, 0x02, 0x9c, 0xad, 0x87, 0x73, 0xae, + 0xaa, 0xea, 0x32, 0xfb, 0x07, 0x4e, 0xcb, 0xe9, 0xac, 0xac, 0x50, 0x0f, + 0x49, 0xb7, 0x23, 0x3b, 0x1f, 0xb2, 0x24, 0x46, 0x78, 0x32, 0x11, 0x9e, + 0xa2, 0xeb, 0xd8, 0x8b, 0x7e, 0x56, 0x92, 0xaa, 0x29, 0xbd, 0x55, 0xc8, + 0x3e, 0x69, 0xe2, 0x56, 0xf4, 0x24, 0x58, 0x7b, 0xf8, 0xb0, 0xbb, 0x72, + 0xb7, 0x38, 0x34, 0xe3, 0x0f, 0x30, 0xf4, 0xfd, 0x44, 0xf1, 0x53, 0x0f, + 0xc5, 0x31, 0xd6, 0xad, 0x45, 0xbf, 0x57, 0x2c, 0x4c, 0xe5, 0x1a, 0xc0, + 0x08, 0x25, 0x88, 0x2f, 0xca, 0x07, 0x2e, 0x35, 0x31, 0xa7, 0x40, 0x3a, + 0x71, 0x1d, 0xba, 0x09, 0xf8, 0x76, 0x6c, 0x69, 0xb2, 0x89, 0xd7, 0xbe, + 0xca, 0x9d, 0xf5, 0xd4, 0x7d, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, + 0x03, 0x87, 0x30, 0x82, 0x03, 0x83, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, + 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, + 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, + 0x76, 0xb9, 0xf4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, + 0x04, 0x14, 0x22, 0x68, 0x57, 0xb9, 0xc0, 0x1f, 0xce, 0xa6, 0xbf, 0xb6, + 0x55, 0xcb, 0x2a, 0x1b, 0xe6, 0xe0, 0x76, 0x94, 0x07, 0x06, 0x30, 0x35, + 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x2e, 0x30, 0x2c, 0x82, 0x15, 0x2a, + 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, 0x61, 0x6d, 0x70, 0x6f, 0x77, + 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x13, 0x63, 0x6d, + 0x2e, 0x73, 0x74, 0x65, 0x61, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, + 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, + 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x1d, 0x06, + 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, + 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, + 0x05, 0x07, 0x03, 0x02, 0x30, 0x81, 0x8b, 0x06, 0x03, 0x55, 0x1d, 0x1f, + 0x04, 0x81, 0x83, 0x30, 0x81, 0x80, 0x30, 0x3e, 0xa0, 0x3c, 0xa0, 0x3a, + 0x86, 0x38, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, + 0x33, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x54, + 0x4c, 0x53, 0x52, 0x53, 0x41, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x32, + 0x30, 0x32, 0x30, 0x43, 0x41, 0x31, 0x2e, 0x63, 0x72, 0x6c, 0x30, 0x3e, + 0xa0, 0x3c, 0xa0, 0x3a, 0x86, 0x38, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x63, 0x72, 0x6c, 0x34, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, + 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, + 0x65, 0x72, 0x74, 0x54, 0x4c, 0x53, 0x52, 0x53, 0x41, 0x53, 0x48, 0x41, + 0x32, 0x35, 0x36, 0x32, 0x30, 0x32, 0x30, 0x43, 0x41, 0x31, 0x2e, 0x63, + 0x72, 0x6c, 0x30, 0x3e, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x37, 0x30, + 0x35, 0x30, 0x33, 0x06, 0x06, 0x67, 0x81, 0x0c, 0x01, 0x02, 0x02, 0x30, + 0x29, 0x30, 0x27, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, + 0x01, 0x16, 0x1b, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, + 0x77, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x43, 0x50, 0x53, 0x30, 0x7d, 0x06, 0x08, 0x2b, 0x06, + 0x01, 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, 0x71, 0x30, 0x6f, 0x30, 0x24, + 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x18, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, + 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, + 0x30, 0x47, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, + 0x86, 0x3b, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x61, 0x63, + 0x65, 0x72, 0x74, 0x73, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, + 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, + 0x72, 0x74, 0x54, 0x4c, 0x53, 0x52, 0x53, 0x41, 0x53, 0x48, 0x41, 0x32, + 0x35, 0x36, 0x32, 0x30, 0x32, 0x30, 0x43, 0x41, 0x31, 0x2e, 0x63, 0x72, + 0x74, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, + 0x02, 0x30, 0x00, 0x30, 0x82, 0x01, 0x7e, 0x06, 0x0a, 0x2b, 0x06, 0x01, + 0x04, 0x01, 0xd6, 0x79, 0x02, 0x04, 0x02, 0x04, 0x82, 0x01, 0x6e, 0x04, + 0x82, 0x01, 0x6a, 0x01, 0x68, 0x00, 0x76, 0x00, 0x29, 0x79, 0xbe, 0xf0, + 0x9e, 0x39, 0x39, 0x21, 0xf0, 0x56, 0x73, 0x9f, 0x63, 0xa5, 0x77, 0xe5, + 0xbe, 0x57, 0x7d, 0x9c, 0x60, 0x0a, 0xf8, 0xf9, 0x4d, 0x5d, 0x26, 0x5c, + 0x25, 0x5d, 0xc7, 0x84, 0x00, 0x00, 0x01, 0x79, 0x19, 0x43, 0x10, 0x65, + 0x00, 0x00, 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0x93, + 0x5f, 0x66, 0xe4, 0xfe, 0x76, 0x25, 0xe6, 0x07, 0x74, 0xa1, 0x8b, 0x7f, + 0x37, 0xad, 0xb1, 0x40, 0x8f, 0x20, 0x66, 0x71, 0x57, 0x14, 0x2c, 0x2e, + 0x28, 0xe0, 0xb2, 0x95, 0xd5, 0x19, 0xd0, 0x02, 0x20, 0x32, 0xd1, 0xa8, + 0x59, 0xfd, 0x69, 0x24, 0x8a, 0x27, 0x7e, 0x56, 0x06, 0xce, 0x6d, 0xeb, + 0xa1, 0xc6, 0x2a, 0xce, 0x4b, 0x37, 0xb1, 0x25, 0xca, 0x6d, 0xd3, 0x43, + 0xf3, 0xdb, 0xb8, 0xa5, 0x5e, 0x00, 0x76, 0x00, 0x22, 0x45, 0x45, 0x07, + 0x59, 0x55, 0x24, 0x56, 0x96, 0x3f, 0xa1, 0x2f, 0xf1, 0xf7, 0x6d, 0x86, + 0xe0, 0x23, 0x26, 0x63, 0xad, 0xc0, 0x4b, 0x7f, 0x5d, 0xc6, 0x83, 0x5c, + 0x6e, 0xe2, 0x0f, 0x02, 0x00, 0x00, 0x01, 0x79, 0x19, 0x43, 0x10, 0xa4, + 0x00, 0x00, 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x20, 0x3a, 0x73, + 0x53, 0xfb, 0xbb, 0x42, 0xdf, 0x2e, 0xa2, 0xc0, 0xc5, 0x29, 0x57, 0xda, + 0xb9, 0x0b, 0x76, 0x58, 0xb6, 0xeb, 0xd3, 0x4d, 0x10, 0x95, 0x1b, 0x58, + 0x3e, 0x58, 0x86, 0xea, 0xec, 0xe5, 0x02, 0x21, 0x00, 0xeb, 0xb2, 0xfe, + 0x83, 0x74, 0xdf, 0xb5, 0xfd, 0x8f, 0x74, 0x82, 0xd3, 0x8f, 0x6b, 0xce, + 0x63, 0x8b, 0x93, 0x94, 0x08, 0x7b, 0x1c, 0x6b, 0x48, 0xae, 0x59, 0xa1, + 0x7e, 0xec, 0x59, 0xdf, 0x56, 0x00, 0x76, 0x00, 0x51, 0xa3, 0xb0, 0xf5, + 0xfd, 0x01, 0x79, 0x9c, 0x56, 0x6d, 0xb8, 0x37, 0x78, 0x8f, 0x0c, 0xa4, + 0x7a, 0xcc, 0x1b, 0x27, 0xcb, 0xf7, 0x9e, 0x88, 0x42, 0x9a, 0x0d, 0xfe, + 0xd4, 0x8b, 0x05, 0xe5, 0x00, 0x00, 0x01, 0x79, 0x19, 0x43, 0x10, 0xea, + 0x00, 0x00, 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x20, 0x68, 0x89, + 0x8b, 0xab, 0x98, 0xd3, 0x4f, 0x41, 0x4f, 0x7d, 0x1c, 0x52, 0xbe, 0x1b, + 0xf1, 0xbe, 0xb3, 0x68, 0x49, 0x5a, 0x91, 0x93, 0xdc, 0xac, 0xba, 0x6e, + 0x58, 0x8d, 0xcd, 0x3c, 0x5a, 0x26, 0x02, 0x21, 0x00, 0x85, 0x09, 0xf7, + 0x21, 0x4a, 0x66, 0x45, 0x77, 0xfe, 0xd5, 0x77, 0x25, 0xd5, 0xc5, 0x1a, + 0xb3, 0x33, 0xd8, 0x86, 0x52, 0xcc, 0xe1, 0x26, 0x21, 0x03, 0xcf, 0x1b, + 0x34, 0x24, 0xab, 0xc0, 0x1f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, + 0x00, 0xbd, 0x22, 0x40, 0xf1, 0x6d, 0xe7, 0x68, 0x89, 0x82, 0x53, 0xcd, + 0x64, 0xed, 0x21, 0x17, 0x90, 0x3a, 0xd0, 0xa3, 0x21, 0x42, 0x40, 0x60, + 0xf2, 0x2c, 0xf7, 0x40, 0xef, 0xc3, 0xf0, 0x22, 0x24, 0xc2, 0x51, 0x17, + 0x9d, 0x4b, 0x10, 0x9f, 0x86, 0x1a, 0x05, 0x4c, 0x6a, 0xe0, 0x13, 0xbb, + 0x29, 0xad, 0xf7, 0x18, 0x5f, 0x76, 0x01, 0x10, 0x8b, 0x1c, 0x29, 0x79, + 0x23, 0x94, 0x58, 0x1a, 0xa6, 0xf8, 0xac, 0x9b, 0x2e, 0xe0, 0x70, 0x1d, + 0x06, 0x1a, 0xe9, 0x5d, 0x24, 0x9f, 0x03, 0xff, 0x40, 0xe5, 0xc1, 0xb0, + 0xb9, 0xa7, 0x7e, 0x19, 0x3d, 0x0c, 0x99, 0x89, 0x81, 0xe4, 0x53, 0x9b, + 0xbd, 0x66, 0x1b, 0xba, 0x2e, 0xcd, 0xff, 0x24, 0x16, 0xd2, 0x89, 0xc9, + 0x75, 0xdd, 0xc9, 0x78, 0x25, 0x1e, 0x11, 0x43, 0x25, 0x06, 0x15, 0xe5, + 0xe3, 0x6b, 0xf9, 0x33, 0xee, 0x06, 0x16, 0x92, 0x8e, 0xe1, 0x8a, 0x93, + 0x41, 0x15, 0x8b, 0xf1, 0x06, 0xf7, 0x52, 0x07, 0x25, 0xb8, 0x6a, 0xae, + 0x46, 0x70, 0xa6, 0x81, 0x74, 0x70, 0x3c, 0x50, 0x42, 0x85, 0x65, 0x41, + 0xdb, 0x25, 0xb3, 0x4f, 0xce, 0x25, 0xb5, 0x2b, 0x62, 0xb7, 0x2b, 0xbf, + 0x66, 0xc4, 0xb4, 0x8a, 0x10, 0xb0, 0x50, 0x8e, 0x84, 0xf8, 0xe5, 0x28, + 0x86, 0xda, 0x7d, 0xe6, 0x65, 0xbf, 0xb1, 0xd5, 0x7d, 0x09, 0x28, 0x61, + 0xa3, 0x14, 0x89, 0x23, 0x35, 0x6e, 0x9c, 0x70, 0x06, 0x8b, 0xcb, 0x84, + 0xe8, 0x70, 0x8d, 0xb9, 0xfb, 0x74, 0xcf, 0x77, 0x63, 0x00, 0x5d, 0x8c, + 0xbb, 0x62, 0x4a, 0x2b, 0xc2, 0x8b, 0x2c, 0xd9, 0x9a, 0xa8, 0x83, 0x6f, + 0x06, 0x2a, 0x2a, 0x30, 0x4c, 0x39, 0xb4, 0xf8, 0x7d, 0x8c, 0x5e, 0xa7, + 0xcb, 0xce, 0x64, 0xe0, 0x27, 0xfa, 0x24, 0x42, 0xdd, 0xd1, 0x1d, 0xf8, + 0xa9, 0xd7, 0xc4, 0x0c, 0x92 +}; + +static const BYTE ocsp_cert_issuer[] = { + 0x30, 0x82, 0x04, 0xbe, 0x30, 0x82, 0x03, 0xa6, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x10, 0x06, 0xd8, 0xd9, 0x04, 0xd5, 0x58, 0x43, 0x46, 0xf6, + 0x8a, 0x2f, 0xa7, 0x54, 0x22, 0x7e, 0xc4, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x61, + 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, + 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0c, + 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, + 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x10, 0x77, + 0x77, 0x77, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, + 0x63, 0x6f, 0x6d, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x03, 0x55, 0x04, 0x03, + 0x13, 0x17, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x47, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, + 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x34, 0x31, 0x34, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x33, 0x31, 0x30, 0x34, + 0x31, 0x33, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x4f, 0x31, + 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, + 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0c, 0x44, + 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x31, + 0x29, 0x30, 0x27, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x20, 0x44, 0x69, + 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x54, 0x4c, 0x53, 0x20, 0x52, + 0x53, 0x41, 0x20, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x32, 0x30, + 0x32, 0x30, 0x20, 0x43, 0x41, 0x31, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, + 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, + 0x01, 0x01, 0x00, 0xc1, 0x4b, 0xb3, 0x65, 0x47, 0x70, 0xbc, 0xdd, 0x4f, + 0x58, 0xdb, 0xec, 0x9c, 0xed, 0xc3, 0x66, 0xe5, 0x1f, 0x31, 0x13, 0x54, + 0xad, 0x4a, 0x66, 0x46, 0x1f, 0x2c, 0x0a, 0xec, 0x64, 0x07, 0xe5, 0x2e, + 0xdc, 0xdc, 0xb9, 0x0a, 0x20, 0xed, 0xdf, 0xe3, 0xc4, 0xd0, 0x9e, 0x9a, + 0xa9, 0x7a, 0x1d, 0x82, 0x88, 0xe5, 0x11, 0x56, 0xdb, 0x1e, 0x9f, 0x58, + 0xc2, 0x51, 0xe7, 0x2c, 0x34, 0x0d, 0x2e, 0xd2, 0x92, 0xe1, 0x56, 0xcb, + 0xf1, 0x79, 0x5f, 0xb3, 0xbb, 0x87, 0xca, 0x25, 0x03, 0x7b, 0x9a, 0x52, + 0x41, 0x66, 0x10, 0x60, 0x4f, 0x57, 0x13, 0x49, 0xf0, 0xe8, 0x37, 0x67, + 0x83, 0xdf, 0xe7, 0xd3, 0x4b, 0x67, 0x4c, 0x22, 0x51, 0xa6, 0xdf, 0x0e, + 0x99, 0x10, 0xed, 0x57, 0x51, 0x74, 0x26, 0xe2, 0x7d, 0xc7, 0xca, 0x62, + 0x2e, 0x13, 0x1b, 0x7f, 0x23, 0x88, 0x25, 0x53, 0x6f, 0xc1, 0x34, 0x58, + 0x00, 0x8b, 0x84, 0xff, 0xf8, 0xbe, 0xa7, 0x58, 0x49, 0x22, 0x7b, 0x96, + 0xad, 0xa2, 0x88, 0x9b, 0x15, 0xbc, 0xa0, 0x7c, 0xdf, 0xe9, 0x51, 0xa8, + 0xd5, 0xb0, 0xed, 0x37, 0xe2, 0x36, 0xb4, 0x82, 0x4b, 0x62, 0xb5, 0x49, + 0x9a, 0xec, 0xc7, 0x67, 0xd6, 0xe3, 0x3e, 0xf5, 0xe3, 0xd6, 0x12, 0x5e, + 0x44, 0xf1, 0xbf, 0x71, 0x42, 0x7d, 0x58, 0x84, 0x03, 0x80, 0xb1, 0x81, + 0x01, 0xfa, 0xf9, 0xca, 0x32, 0xbb, 0xb4, 0x8e, 0x27, 0x87, 0x27, 0xc5, + 0x2b, 0x74, 0xd4, 0xa8, 0xd6, 0x97, 0xde, 0xc3, 0x64, 0xf9, 0xca, 0xce, + 0x53, 0xa2, 0x56, 0xbc, 0x78, 0x17, 0x8e, 0x49, 0x03, 0x29, 0xae, 0xfb, + 0x49, 0x4f, 0xa4, 0x15, 0xb9, 0xce, 0xf2, 0x5c, 0x19, 0x57, 0x6d, 0x6b, + 0x79, 0xa7, 0x2b, 0xa2, 0x27, 0x20, 0x13, 0xb5, 0xd0, 0x3d, 0x40, 0xd3, + 0x21, 0x30, 0x07, 0x93, 0xea, 0x99, 0xf5, 0x02, 0x03, 0x01, 0x00, 0x01, + 0xa3, 0x82, 0x01, 0x82, 0x30, 0x82, 0x01, 0x7e, 0x30, 0x12, 0x06, 0x03, + 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, + 0xff, 0x02, 0x01, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, + 0x16, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, + 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x30, + 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, + 0x03, 0xde, 0x50, 0x35, 0x56, 0xd1, 0x4c, 0xbb, 0x66, 0xf0, 0xa3, 0xe2, + 0x1b, 0x1b, 0xc3, 0x97, 0xb2, 0x3d, 0xd1, 0x55, 0x30, 0x0e, 0x06, 0x03, + 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, + 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x76, 0x06, 0x08, 0x2b, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, 0x6a, 0x30, 0x68, 0x30, + 0x24, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, + 0x18, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, + 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, 0x6f, + 0x6d, 0x30, 0x40, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, + 0x02, 0x86, 0x34, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x61, + 0x63, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, + 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, + 0x65, 0x72, 0x74, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x52, 0x6f, 0x6f, + 0x74, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x42, 0x06, 0x03, 0x55, + 0x1d, 0x1f, 0x04, 0x3b, 0x30, 0x39, 0x30, 0x37, 0xa0, 0x35, 0xa0, 0x33, + 0x86, 0x31, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, + 0x33, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x47, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x43, 0x41, 0x2e, + 0x63, 0x72, 0x6c, 0x30, 0x3d, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x36, + 0x30, 0x34, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xfd, + 0x6c, 0x02, 0x01, 0x30, 0x07, 0x06, 0x05, 0x67, 0x81, 0x0c, 0x01, 0x01, + 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0c, 0x01, 0x02, 0x01, 0x30, 0x08, + 0x06, 0x06, 0x67, 0x81, 0x0c, 0x01, 0x02, 0x02, 0x30, 0x08, 0x06, 0x06, + 0x67, 0x81, 0x0c, 0x01, 0x02, 0x03, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, + 0x01, 0x00, 0x80, 0x32, 0xce, 0x5e, 0x0b, 0xdd, 0x6e, 0x5a, 0x0d, 0x0a, + 0xaf, 0xe1, 0xd6, 0x84, 0xcb, 0xc0, 0x8e, 0xfa, 0x85, 0x70, 0xed, 0xda, + 0x5d, 0xb3, 0x0c, 0xf7, 0x2b, 0x75, 0x40, 0xfe, 0x85, 0x0a, 0xfa, 0xf3, + 0x31, 0x78, 0xb7, 0x70, 0x4b, 0x1a, 0x89, 0x58, 0xba, 0x80, 0xbd, 0xf3, + 0x6b, 0x1d, 0xe9, 0x7e, 0xcf, 0x0b, 0xba, 0x58, 0x9c, 0x59, 0xd4, 0x90, + 0xd3, 0xfd, 0x6c, 0xfd, 0xd0, 0x98, 0x6d, 0xb7, 0x71, 0x82, 0x5b, 0xcf, + 0x6d, 0x0b, 0x5a, 0x09, 0xd0, 0x7b, 0xde, 0xc4, 0x43, 0xd8, 0x2a, 0xa4, + 0xde, 0x9e, 0x41, 0x26, 0x5f, 0xbb, 0x8f, 0x99, 0xcb, 0xdd, 0xae, 0xe1, + 0xa8, 0x6f, 0x9f, 0x87, 0xfe, 0x74, 0xb7, 0x1f, 0x1b, 0x20, 0xab, 0xb1, + 0x4f, 0xc6, 0xf5, 0x67, 0x5d, 0x5d, 0x9b, 0x3c, 0xe9, 0xff, 0x69, 0xf7, + 0x61, 0x6c, 0xd6, 0xd9, 0xf3, 0xfd, 0x36, 0xc6, 0xab, 0x03, 0x88, 0x76, + 0xd2, 0x4b, 0x2e, 0x75, 0x86, 0xe3, 0xfc, 0xd8, 0x55, 0x7d, 0x26, 0xc2, + 0x11, 0x77, 0xdf, 0x3e, 0x02, 0xb6, 0x7c, 0xf3, 0xab, 0x7b, 0x7a, 0x86, + 0x36, 0x6f, 0xb8, 0xf7, 0xd8, 0x93, 0x71, 0xcf, 0x86, 0xdf, 0x73, 0x30, + 0xfa, 0x7b, 0xab, 0xed, 0x2a, 0x59, 0xc8, 0x42, 0x84, 0x3b, 0x11, 0x17, + 0x1a, 0x52, 0xf3, 0xc9, 0x0e, 0x14, 0x7d, 0xa2, 0x5b, 0x72, 0x67, 0xba, + 0x71, 0xed, 0x57, 0x47, 0x66, 0xc5, 0xb8, 0x02, 0x4a, 0x65, 0x34, 0x5e, + 0x8b, 0xd0, 0x2a, 0x3c, 0x20, 0x9c, 0x51, 0x99, 0x4c, 0xe7, 0x52, 0x9e, + 0xf7, 0x6b, 0x11, 0x2b, 0x0d, 0x92, 0x7e, 0x1d, 0xe8, 0x8a, 0xeb, 0x36, + 0x16, 0x43, 0x87, 0xea, 0x2a, 0x63, 0xbf, 0x75, 0x3f, 0xeb, 0xde, 0xc4, + 0x03, 0xbb, 0x0a, 0x3c, 0xf7, 0x30, 0xef, 0xeb, 0xaf, 0x4c, 0xfc, 0x8b, + 0x36, 0x10, 0x73, 0x3e, 0xf3, 0xa4 +}; + static void testVerifyRevocation(void) { BOOL ret; @@ -3607,24 +3898,24 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); status.cbSize = sizeof(status); ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status); - ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError()); ret = CertVerifyRevocation(0, 2, 0, NULL, 0, NULL, &status); - ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError()); ret = CertVerifyRevocation(2, 0, 0, NULL, 0, NULL, &status); - ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError()); certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 0, 1, (void **)certs, 0, NULL, &status); ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL, - "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError()); + "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 2, 1, (void **)certs, 0, NULL, &status); ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL, - "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError()); + "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError()); CertFreeCertificateContext(certs[0]); @@ -3636,42 +3927,33 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)certs, 0, NULL, &status); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("CERT_CONTEXT_REVOCATION_TYPE unsupported, skipping\n"); - return; - } ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError()); ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); /* Neither can the end cert */ SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[1], 0, NULL, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE), - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(!ret && (GetLastError() == CRYPT_E_REVOCATION_OFFLINE || GetLastError() == CRYPT_E_NO_REVOCATION_CHECK), + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ || - status.dwError == CRYPT_E_REVOCATION_OFFLINE, - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE || status.dwError == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); /* Both certs together can't, either (they're not CRLs) */ SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, 0, NULL, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */), - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */, - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); /* Now add a CRL to the hCrlStore */ revPara.hCrlStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); @@ -3680,42 +3962,57 @@ static void testVerifyRevocation(void) SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, 0, &revPara, &status); - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */), - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */, - "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n", + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); /* Specifying CERT_VERIFY_REV_CHAIN_FLAG doesn't change things either */ SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, CERT_VERIFY_REV_CHAIN_FLAG, &revPara, &status); ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError()); ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); /* Again, specifying the issuer cert: no change */ revPara.pIssuerCert = certs[0]; SetLastError(0xdeadbeef); ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[1], 0, &revPara, &status); - /* Win2k thinks the cert is revoked, and it is, except the CRL is out of - * date, hence the revocation status should be unknown. - */ - ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK || - broken(GetLastError() == CRYPT_E_REVOKED /* Win2k */)), - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError()); - ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK || - broken(status.dwError == CRYPT_E_REVOKED /* Win2k */), - "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError); - ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex); + ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError()); + ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, + "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError); + ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex); CertCloseStore(revPara.hCrlStore, 0); CertFreeCertificateContext(certs[1]); CertFreeCertificateContext(certs[0]); + + /* OCSP */ + certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING, ocsp_cert, sizeof(ocsp_cert)); + memset(&revPara, 0, sizeof(revPara)); + revPara.cbSize = sizeof(revPara); + memset(&status, 0x55, sizeof(status)); + status.cbSize = sizeof(status); + SetLastError(0xdeadbeef); + ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[0], + 0, &revPara, &status); + ok(!ret, "success\n"); + ok(GetLastError() == CRYPT_E_REVOCATION_OFFLINE, "got %08lx\n", GetLastError()); + + revPara.pIssuerCert = CertCreateCertificateContext(X509_ASN_ENCODING, ocsp_cert_issuer, + sizeof(ocsp_cert_issuer)); + ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[0], + 0, &revPara, &status); + ok(ret, "got %08lx\n", GetLastError()); + ok(!status.dwError, "got %08lx\n", status.dwError); + ok(!status.dwIndex, "got %ld\n", status.dwIndex); + CertFreeCertificateContext(revPara.pIssuerCert); + CertFreeCertificateContext(certs[0]); } static BYTE privKey[] = { @@ -3770,15 +4067,9 @@ static void testAcquireCertPrivateKey(void) HCRYPTKEY key; WCHAR ms_def_prov_w[MAX_PATH]; - if (!pCryptAcquireCertificatePrivateKey) - { - win_skip("CryptAcquireCertificatePrivateKey() is not available\n"); - return; - } - lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W); - keyProvInfo.pwszContainerName = cspNameW; + keyProvInfo.pwszContainerName = (WCHAR *)L"WineCryptTemp"; keyProvInfo.pwszProvName = ms_def_prov_w; keyProvInfo.dwProvType = PROV_RSA_FULL; keyProvInfo.dwFlags = 0; @@ -3786,43 +4077,45 @@ static void testAcquireCertPrivateKey(void) keyProvInfo.rgProvParam = NULL; keyProvInfo.dwKeySpec = AT_SIGNATURE; - pCryptAcquireContextA(NULL, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(NULL, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); /* Crash - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, &callerFree); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); - ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, &callerFree); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); */ /* Missing private key */ - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); - ok(!ret && GetLastError() == CRYPT_E_NO_KEY_PROPERTY, - "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); + ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), + "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError()); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); - ok(!ret && GetLastError() == CRYPT_E_NO_KEY_PROPERTY, - "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); + ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), + "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError()); CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); - ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_KEYSET /* win8 */), - "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); + ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || + GetLastError() == NTE_BAD_KEYSET /* win8 */ || + GetLastError() == NTE_BAD_PROV_TYPE /* win10 */), + "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError()); - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_NEWKEYSET); ret = CryptImportKey(csp, privKey, sizeof(privKey), 0, 0, &key); - ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); if (ret) { HCRYPTPROV certCSP; @@ -3830,55 +4123,42 @@ static void testAcquireCertPrivateKey(void) CERT_KEY_CONTEXT keyContext; /* Don't cache provider */ - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + SetLastError(0xdeadbeef); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); - if (ret) - { - ok(callerFree, "Expected callerFree to be TRUE\n"); - CryptReleaseContext(certCSP, 0); - } + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError()); + ok(callerFree, "Expected callerFree to be TRUE\n"); + CryptReleaseContext(certCSP, 0); - ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + SetLastError(0xdeadbeef); + ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, NULL, NULL); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError()); CryptReleaseContext(certCSP, 0); /* Use the key prov info's caching (there shouldn't be any) */ - ret = pCryptAcquireCertificatePrivateKey(cert, + SetLastError(0xdeadbeef); + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); - if (ret) - { - ok(callerFree, "Expected callerFree to be TRUE\n"); - CryptReleaseContext(certCSP, 0); - } + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError()); + ok(callerFree, "Expected callerFree to be TRUE\n"); + CryptReleaseContext(certCSP, 0); /* Cache it (and check that it's cached) */ - ret = pCryptAcquireCertificatePrivateKey(cert, + SetLastError(0xdeadbeef); + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError()); ok(!callerFree, "Expected callerFree to be FALSE\n"); size = sizeof(keyContext); ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); - ok(ret || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08x\n", - GetLastError()); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); /* Remove the cached provider */ CryptReleaseContext(keyContext.hCryptProv, 0); @@ -3889,21 +4169,17 @@ static void testAcquireCertPrivateKey(void) CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); /* Now use the key prov info's caching */ - ret = pCryptAcquireCertificatePrivateKey(cert, + SetLastError(0xdeadbeef); + ret = CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError()); ok(!callerFree, "Expected callerFree to be FALSE\n"); size = sizeof(keyContext); ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); - ok(ret || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08x\n", - GetLastError()); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); CryptReleaseContext(certCSP, 0); CryptDestroyKey(key); @@ -3912,57 +4188,57 @@ static void testAcquireCertPrivateKey(void) /* Some sanity-checking on public key exporting */ ret = CryptImportPublicKeyInfo(csp, X509_ASN_ENCODING, &cert->pCertInfo->SubjectPublicKeyInfo, &key); - ok(ret, "CryptImportPublicKeyInfo failed: %08x\n", GetLastError()); + ok(ret, "CryptImportPublicKeyInfo failed: %08lx\n", GetLastError()); if (ret) { ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, NULL, &size); - ok(ret, "CryptExportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptExportKey failed: %08lx\n", GetLastError()); if (ret) { - LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size), encodedKey; + LPBYTE buf = malloc(size), encodedKey; ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, buf, &size); - ok(ret, "CryptExportKey failed: %08x\n", GetLastError()); - ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %d\n", + ok(ret, "CryptExportKey failed: %08lx\n", GetLastError()); + ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %ld\n", size); ok(!memcmp(buf, exportedPublicKeyBlob, size), "Unexpected value\n"); - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, buf, CRYPT_ENCODE_ALLOC_FLAG, NULL, &encodedKey, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(asnEncodedPublicKey), "Unexpected size %d\n", + ok(size == sizeof(asnEncodedPublicKey), "Unexpected size %ld\n", size); ok(!memcmp(encodedKey, asnEncodedPublicKey, size), "Unexpected value\n"); LocalFree(encodedKey); } - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } CryptDestroyKey(key); } ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, NULL, &size); - ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError()); + ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError()); if (ret) { - PCERT_PUBLIC_KEY_INFO info = HeapAlloc(GetProcessHeap(), 0, size); + PCERT_PUBLIC_KEY_INFO info = malloc(size); ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, info, &size); - ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError()); + ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->PublicKey.cbData == sizeof(asnEncodedPublicKey), - "Unexpected size %d\n", info->PublicKey.cbData); + "Unexpected size %ld\n", info->PublicKey.cbData); ok(!memcmp(info->PublicKey.pbData, asnEncodedPublicKey, info->PublicKey.cbData), "Unexpected value\n"); } - HeapFree(GetProcessHeap(), 0, info); + free(info); } CryptReleaseContext(csp, 0); - pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); CertFreeCertificateContext(cert); @@ -3986,28 +4262,24 @@ static void testGetPublicKeyLength(void) SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(0, &info); ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n", + "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "Expected length 0 and CRYPT_E_ASN1_EOD, got length %d, %08x\n", + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n", ret, GetLastError()); /* With a nearly-empty public key info */ info.Algorithm.pszObjId = oid_rsa_rsa; SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(0, &info); ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n", + "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "Expected length 0 and CRYPT_E_ASN1_EOD, got length %d, %08x\n", + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n", ret, GetLastError()); /* With a bogus key */ info.PublicKey.cbData = sizeof(bogusKey); @@ -4015,14 +4287,12 @@ static void testGetPublicKeyLength(void) SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(0, &info); ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n", + "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH), /* win9x */ - "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %d, %08x\n", + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %ld, %08lx\n", ret, GetLastError()); /* With a believable RSA key but a bogus OID */ info.Algorithm.pszObjId = bogusOID; @@ -4031,39 +4301,220 @@ static void testGetPublicKeyLength(void) SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(0, &info); ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n", + "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */, - "Expected length 56, got %d\n", ret); + "Expected length 56, got %ld\n", ret); /* An RSA key with the DH OID */ info.Algorithm.pszObjId = oid_rsa_dh; SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); - ok(ret == 0 && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == E_INVALIDARG), /* win9x */ - "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %d, %08x\n", + ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %ld, %08lx\n", ret, GetLastError()); /* With the RSA OID */ info.Algorithm.pszObjId = oid_rsa_rsa; SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info); ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */, - "Expected length 56, got %d\n", ret); + "Expected length 56, got %ld\n", ret); /* With the RSA OID and a message encoding */ info.Algorithm.pszObjId = oid_rsa_rsa; SetLastError(0xdeadbeef); ret = CertGetPublicKeyLength(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, &info); ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */, - "Expected length 56, got %d\n", ret); + "Expected length 56, got %ld\n", ret); +} + +static void testKeyProvInfo(void) +{ + static WCHAR containerW[] = L"Wine Test Container"; + static WCHAR providerW[] = L"Hello World CSP"; + static CRYPT_KEY_PROV_PARAM param[2] = { { 0x4444, (BYTE *)"param", 6, 0x5555 }, { 0x7777, (BYTE *)"param2", 7, 0x8888 } }; + HCERTSTORE store; + const CERT_CONTEXT *cert; + CERT_NAME_BLOB name; + CRYPT_KEY_PROV_INFO *info, info2; + BOOL ret; + DWORD size; + + store = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER, "My"); + ok(store != NULL, "CertOpenStore error %lu\n", GetLastError()); + + cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); + ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError()); + + info2.pwszContainerName = containerW; + info2.pwszProvName = providerW; + info2.dwProvType = 0x12345678; + info2.dwFlags = 0x87654321; + info2.cProvParam = ARRAY_SIZE(param); + info2.rgProvParam = param; + info2.dwKeySpec = 0x11223344; + ret = CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &info2); + ok(ret, "CertSetCertificateContextProperty error %#lx\n", GetLastError()); + + ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size); + ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError()); + info = malloc(size); + ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size); + ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError()); + ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName)); + ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName)); + ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType); + ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags); + ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec); + ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam); + ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam); + ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam); + ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData); + ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n"); + ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags); + ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam); + ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData); + ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n"); + ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags); + free(info); + + ret = CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_NEW, NULL); + ok(ret, "CertAddCertificateContextToStore error %#lx\n", GetLastError()); + + CertFreeCertificateContext(cert); + CertCloseStore(store, 0); + + store = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My"); + ok(store != NULL, "CertOpenStore error %lu\n", GetLastError()); + + name.pbData = subjectName; + name.cbData = sizeof(subjectName); + cert = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_NAME, &name, NULL); + ok(cert != NULL, "certificate should exist in My store\n"); + + ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size); + ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError()); + info = malloc(size); + ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size); + ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError()); + ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName)); + ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName)); + ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType); + ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags); + ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec); + ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam); + ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam); + ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam); + ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData); + ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n"); + ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags); + ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam); + ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData); + ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n"); + ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags); + free(info); + + ret = CertDeleteCertificateFromStore(cert); + ok(ret, "CertDeleteCertificateFromStore error %#lx\n", GetLastError()); + + CertFreeCertificateContext(cert); + CertCloseStore(store, 0); +} + +static void test_VerifySignature(void) +{ + PCCERT_CONTEXT cert; + PCERT_SIGNED_CONTENT_INFO info; + DWORD size; + BOOL ret; + HCRYPTPROV prov; + HCRYPTKEY key; + HCRYPTHASH hash; +#ifndef __REACTOS__ + BYTE hash_value[20], *sig_value; + DWORD hash_len, i; + BCRYPT_KEY_HANDLE bkey; + BCRYPT_HASH_HANDLE bhash; + BCRYPT_ALG_HANDLE alg; + BCRYPT_PKCS1_PADDING_INFO pad; + NTSTATUS status; +#endif + + cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); + ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError()); + + /* 1. Verify certificate signature with Crypto API */ + ret = CryptVerifyCertificateSignature(0, cert->dwCertEncodingType, + cert->pbCertEncoded, cert->cbCertEncoded, &cert->pCertInfo->SubjectPublicKeyInfo); + ok(ret, "CryptVerifyCertificateSignature error %#lx\n", GetLastError()); + + /* 2. Verify certificate signature with Crypto API manually */ + ret = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + ok(ret, "CryptAcquireContext error %#lx\n", GetLastError()); + + ret = CryptImportPublicKeyInfoEx(prov, cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key); + ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError()); + + ret = CryptDecodeObjectEx(cert->dwCertEncodingType, X509_CERT, + cert->pbCertEncoded, cert->cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "CryptDecodeObjectEx error %#lx\n", GetLastError()); + + ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash); + ok(ret, "CryptCreateHash error %#lx\n", GetLastError()); + + ret = CryptHashData(hash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0); + ok(ret, "CryptHashData error %#lx\n", GetLastError()); + + ret = CryptVerifySignatureW(hash, info->Signature.pbData, info->Signature.cbData, key, NULL, 0); + ok(ret, "CryptVerifySignature error %#lx\n", GetLastError()); + + CryptDestroyHash(hash); + CryptDestroyKey(key); + CryptReleaseContext(prov, 0); + +#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptImportPublicKeyInfoEx2 + /* 3. Verify certificate signature with CNG */ + ret = CryptImportPublicKeyInfoEx2(cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &bkey); + ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError()); + + status = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA1_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); + ok(!status, "got %#lx\n", status); + + status = BCryptCreateHash(alg, &bhash, NULL, 0, NULL, 0, 0); + ok(!status, "got %#lx\n", status); + + status = BCryptHashData(bhash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0); + ok(!status, "got %#lx\n", status); + + status = BCryptFinishHash(bhash, hash_value, sizeof(hash_value), 0); + ok(!status, "got %#lx\n", status); + ok(!memcmp(hash_value, selfSignedSignatureHash, sizeof(hash_value)), "got wrong hash value\n"); + + status = BCryptGetProperty(bhash, BCRYPT_HASH_LENGTH, (BYTE *)&hash_len, sizeof(hash_len), &size, 0); + ok(!status, "got %#lx\n", status); + ok(hash_len == sizeof(hash_value), "got %lu\n", hash_len); + + sig_value = malloc(info->Signature.cbData); + for (i = 0; i < info->Signature.cbData; i++) + sig_value[i] = info->Signature.pbData[info->Signature.cbData - i - 1]; + + pad.pszAlgId = BCRYPT_SHA1_ALGORITHM; + status = BCryptVerifySignature(bkey, &pad, hash_value, sizeof(hash_value), sig_value, info->Signature.cbData, BCRYPT_PAD_PKCS1); + ok(!status, "got %#lx\n", status); + + free(sig_value); + BCryptDestroyHash(bhash); + BCryptCloseAlgorithmProvider(alg, 0); + BCryptDestroyKey(bkey); + LocalFree(info); + CertFreeCertificateContext(cert); +#endif } START_TEST(cert) { - init_function_pointers(); - testAddCert(); testCertProperties(); testCreateCert(); @@ -4072,8 +4523,10 @@ START_TEST(cert) testGetSubjectCert(); testGetIssuerCert(); testLinkCert(); + testKeyProvInfo(); testCryptHashCert(); + testCryptHashCert2(); testCertSigs(); testSignAndEncodeCert(); testCreateSelfSignCert(); @@ -4091,4 +4544,5 @@ START_TEST(cert) testAcquireCertPrivateKey(); testGetPublicKeyLength(); testIsRDNAttrsInCertificateName(); + test_VerifySignature(); } diff --git a/modules/rostests/winetests/crypt32/chain.c b/modules/rostests/winetests/crypt32/chain.c index e2a76335263..15087c871c9 100644 --- a/modules/rostests/winetests/crypt32/chain.c +++ b/modules/rostests/winetests/crypt32/chain.c @@ -54,12 +54,6 @@ static const BYTE selfSignedCert[] = { 0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f, 0xa8, 0x76, 0x57, 0x92, 0x36 }; -static BOOL (WINAPI *pCertCreateCertificateChainEngine)(PCERT_CHAIN_ENGINE_CONFIG,HCERTCHAINENGINE*); -static BOOL (WINAPI *pCertGetCertificateChain)(HCERTCHAINENGINE,PCCERT_CONTEXT,LPFILETIME,HCERTSTORE,PCERT_CHAIN_PARA,DWORD,LPVOID,PCCERT_CHAIN_CONTEXT*); -static VOID (WINAPI *pCertFreeCertificateChain)(PCCERT_CHAIN_CONTEXT); -static VOID (WINAPI *pCertFreeCertificateChainEngine)(HCERTCHAINENGINE); -static BOOL (WINAPI *pCertVerifyCertificateChainPolicy)(LPCSTR,PCCERT_CHAIN_CONTEXT,PCERT_CHAIN_POLICY_PARA,PCERT_CHAIN_POLICY_STATUS); - #define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) typedef struct _CERT_CHAIN_ENGINE_CONFIG_NO_EXCLUSIVE_ROOT @@ -84,51 +78,45 @@ static void testCreateCertChainEngine(void) HCERTCHAINENGINE engine; HCERTSTORE store; - if (!pCertCreateCertificateChainEngine || !pCertFreeCertificateChainEngine) - { - win_skip("Cert*CertificateChainEngine() functions are not available\n"); - return; - } - /* Crash - ret = pCertCreateCertificateChainEngine(NULL, NULL); - ret = pCertCreateCertificateChainEngine(NULL, &engine); - ret = pCertCreateCertificateChainEngine(pConfig, NULL); + ret = CertCreateCertificateChainEngine(NULL, NULL); + ret = CertCreateCertificateChainEngine(NULL, &engine); + ret = CertCreateCertificateChainEngine(pConfig, NULL); */ - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Crashes config.cbSize = sizeof(config); - ret = pCertCreateCertificateChainEngine(pConfig, NULL); + ret = CertCreateCertificateChainEngine(pConfig, NULL); */ config.cbSize = sizeof(config); - ret = pCertCreateCertificateChainEngine(pConfig, &engine); - ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); + ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); + CertFreeCertificateChainEngine(engine); config.dwFlags = 0xff000000; - ret = pCertCreateCertificateChainEngine(pConfig, &engine); - ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); + ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); + CertFreeCertificateChainEngine(engine); /* Creating a cert with no root certs at all is allowed.. */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); config.hRestrictedRoot = store; - ret = pCertCreateCertificateChainEngine(pConfig, &engine); - ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - pCertFreeCertificateChainEngine(engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); + ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError()); + CertFreeCertificateChainEngine(engine); /* but creating one with a restricted root with a cert that isn't a member * of the Root store isn't allowed. */ CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert), CERT_STORE_ADD_ALWAYS, NULL); - ret = pCertCreateCertificateChainEngine(pConfig, &engine); + ret = CertCreateCertificateChainEngine(pConfig, &engine); /* ERROR_FILE_NOT_FOUND used in Windows 10 */ ok(!ret && ((GetLastError() == CRYPT_E_NOT_FOUND) || (GetLastError() == ERROR_FILE_NOT_FOUND)), - "Expected CRYPT_E_NOT_FOUND or ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND or ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); CertCloseStore(store, 0); } @@ -402,95 +390,130 @@ static const BYTE google_com[]={ }; /* *.winehq.org cert */ static const BYTE winehq_org[] = { -0x30,0x82,0x05,0x2a,0x30,0x82,0x04,0x12,0xa0,0x03,0x02,0x01,0x02,0x02,0x03, -0x0c,0x35,0xd0,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01, -0x05,0x05,0x00,0x30,0x3c,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13, -0x02,0x55,0x53,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0a,0x13,0x0e,0x47, -0x65,0x6f,0x54,0x72,0x75,0x73,0x74,0x2c,0x20,0x49,0x6e,0x63,0x2e,0x31,0x14, -0x30,0x12,0x06,0x03,0x55,0x04,0x03,0x13,0x0b,0x52,0x61,0x70,0x69,0x64,0x53, -0x53,0x4c,0x20,0x43,0x41,0x30,0x1e,0x17,0x0d,0x31,0x33,0x30,0x35,0x32,0x32, -0x30,0x33,0x35,0x36,0x30,0x39,0x5a,0x17,0x0d,0x31,0x34,0x30,0x35,0x32,0x35, -0x30,0x37,0x33,0x34,0x31,0x34,0x5a,0x30,0x81,0xbb,0x31,0x29,0x30,0x27,0x06, -0x03,0x55,0x04,0x05,0x13,0x20,0x30,0x6d,0x4a,0x75,0x76,0x31,0x74,0x2d,0x31, -0x43,0x46,0x79,0x70,0x51,0x6b,0x79,0x54,0x5a,0x77,0x66,0x76,0x6a,0x48,0x48, -0x42,0x41,0x62,0x6e,0x55,0x6e,0x64,0x47,0x31,0x13,0x30,0x11,0x06,0x03,0x55, -0x04,0x0b,0x13,0x0a,0x47,0x54,0x39,0x38,0x33,0x38,0x30,0x30,0x31,0x31,0x31, -0x31,0x30,0x2f,0x06,0x03,0x55,0x04,0x0b,0x13,0x28,0x53,0x65,0x65,0x20,0x77, -0x77,0x77,0x2e,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x6f,0x6d, -0x2f,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x2f,0x63,0x70,0x73,0x20, -0x28,0x63,0x29,0x31,0x33,0x31,0x2f,0x30,0x2d,0x06,0x03,0x55,0x04,0x0b,0x13, -0x26,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x20,0x43,0x6f,0x6e,0x74,0x72,0x6f,0x6c, -0x20,0x56,0x61,0x6c,0x69,0x64,0x61,0x74,0x65,0x64,0x20,0x2d,0x20,0x52,0x61, -0x70,0x69,0x64,0x53,0x53,0x4c,0x28,0x52,0x29,0x31,0x15,0x30,0x13,0x06,0x03, -0x55,0x04,0x03,0x0c,0x0c,0x2a,0x2e,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f, -0x72,0x67,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7, -0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a, -0x02,0x82,0x01,0x01,0x00,0xc2,0x91,0x35,0xc7,0x67,0x32,0xf1,0x66,0x12,0x38, -0x79,0xdb,0x02,0x11,0x95,0x89,0x1b,0x4a,0x6a,0x63,0x45,0x35,0x58,0x1b,0x57, -0x8d,0xec,0x19,0x88,0xf5,0xa3,0x9e,0x6b,0xdb,0x07,0xfb,0x6e,0x29,0xe9,0xa9, -0x14,0x07,0x8c,0x3a,0xc1,0xd7,0x88,0xcc,0xe4,0x55,0x79,0x6e,0x97,0xe9,0x93, -0x88,0x9a,0x89,0xf9,0x31,0x0f,0x91,0x61,0xc2,0x9c,0xae,0x59,0x25,0x93,0x9a, -0xc8,0xf9,0x28,0x7a,0x0f,0x0f,0x89,0x9a,0xda,0x46,0xbe,0xb2,0xdc,0x90,0x5b, -0xd8,0x87,0xda,0xda,0xce,0x70,0x70,0x95,0x43,0x51,0xa0,0x21,0x22,0x54,0xab, -0xa7,0x09,0xe1,0x81,0x09,0x8c,0x00,0x15,0x30,0x5a,0xa7,0x61,0x77,0xba,0x48, -0x91,0xc6,0x94,0x90,0xdd,0x1a,0xf4,0x3f,0xa6,0x8a,0xb4,0x2f,0x98,0x16,0x0d, -0x96,0x9f,0x0c,0x96,0x01,0x15,0xbc,0x74,0x7e,0x5c,0x4e,0xe3,0x95,0xae,0x00, -0xf5,0x5b,0x88,0x0f,0xef,0x7c,0x1f,0xab,0x22,0xfe,0x95,0x42,0x1a,0xbd,0xee, -0x23,0xca,0x5b,0x7f,0x4a,0xb0,0xbe,0x15,0x65,0xe2,0xce,0x02,0xc4,0xf6,0xb8, -0xf3,0xd6,0x7e,0x75,0x5e,0x63,0x47,0x5d,0xc1,0xca,0xc3,0xc4,0x4a,0xf5,0x4d, -0x66,0x34,0x03,0xf8,0xf4,0x54,0x7d,0x6b,0x54,0x2f,0x17,0x7c,0x39,0x13,0x78, -0x09,0x9e,0xd0,0x9c,0x51,0x02,0x11,0x9d,0xa7,0x53,0x60,0xdd,0x62,0x2b,0xee, -0xb0,0xd1,0xf2,0x1a,0x5c,0xdc,0xa7,0x58,0xc2,0xfa,0x29,0xcf,0xf3,0xc9,0xe9, -0xae,0xe8,0x70,0x60,0x99,0xc7,0x30,0xdd,0x1c,0xda,0x32,0xc0,0x45,0xa5,0x48, -0xc5,0x22,0x29,0x0c,0x74,0x25,0x02,0x03,0x01,0x00,0x01,0xa3,0x82,0x01,0xb3, -0x30,0x82,0x01,0xaf,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16, -0x80,0x14,0x6b,0x69,0x3d,0x6a,0x18,0x42,0x4a,0xdd,0x8f,0x02,0x65,0x39,0xfd, -0x35,0x24,0x86,0x78,0x91,0x16,0x30,0x30,0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01, -0x01,0xff,0x04,0x04,0x03,0x02,0x05,0xa0,0x30,0x1d,0x06,0x03,0x55,0x1d,0x25, -0x04,0x16,0x30,0x14,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x06, -0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x23,0x06,0x03,0x55,0x1d, -0x11,0x04,0x1c,0x30,0x1a,0x82,0x0c,0x2a,0x2e,0x77,0x69,0x6e,0x65,0x68,0x71, -0x2e,0x6f,0x72,0x67,0x82,0x0a,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72, -0x67,0x30,0x43,0x06,0x03,0x55,0x1d,0x1f,0x04,0x3c,0x30,0x3a,0x30,0x38,0xa0, -0x36,0xa0,0x34,0x86,0x32,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x72,0x61,0x70, -0x69,0x64,0x73,0x73,0x6c,0x2d,0x63,0x72,0x6c,0x2e,0x67,0x65,0x6f,0x74,0x72, -0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x63,0x72,0x6c,0x73,0x2f,0x72,0x61, -0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x72,0x6c,0x30,0x1d,0x06,0x03,0x55, -0x1d,0x0e,0x04,0x16,0x04,0x14,0xff,0x4c,0x0f,0x46,0xb8,0x3c,0x5b,0x72,0xe4, -0x10,0x96,0xbb,0xa7,0xbc,0x91,0xa2,0x63,0xf6,0x81,0x0a,0x30,0x0c,0x06,0x03, -0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,0x30,0x00,0x30,0x78,0x06,0x08,0x2b, -0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x6c,0x30,0x6a,0x30,0x2d,0x06,0x08, -0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x21,0x68,0x74,0x74,0x70,0x3a, -0x2f,0x2f,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2d,0x6f,0x63,0x73,0x70, -0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x30,0x39, -0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x2d,0x68,0x74,0x74, -0x70,0x3a,0x2f,0x2f,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2d,0x61,0x69, -0x61,0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x2f, -0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x72,0x74,0x30,0x4c,0x06, -0x03,0x55,0x1d,0x20,0x04,0x45,0x30,0x43,0x30,0x41,0x06,0x0a,0x60,0x86,0x48, -0x01,0x86,0xf8,0x45,0x01,0x07,0x36,0x30,0x33,0x30,0x31,0x06,0x08,0x2b,0x06, -0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x25,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, -0x77,0x77,0x77,0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f, -0x6d,0x2f,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x2f,0x63,0x70,0x73, -0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00, -0x03,0x82,0x01,0x01,0x00,0x1b,0xa8,0x34,0xc1,0xb7,0xf3,0xbe,0xb6,0xed,0x12, -0x85,0x58,0xe1,0x69,0x35,0x0c,0xb8,0x7e,0x38,0x11,0xb3,0xd2,0xe2,0x2e,0x52, -0xcf,0xa6,0x39,0xe1,0x25,0x73,0xf0,0x1d,0xc9,0x54,0xa1,0xc2,0x50,0x19,0xea, -0x68,0xeb,0x1a,0x21,0xdb,0x86,0x14,0x55,0x73,0x02,0x28,0x56,0x14,0xf7,0xf1, -0x48,0x43,0xfb,0xd7,0xbf,0xcf,0xbb,0x20,0xc4,0x1e,0x4e,0x9a,0x7c,0xf1,0xe8, -0x28,0x76,0xce,0xf9,0xb3,0xf0,0x6f,0x93,0x70,0x51,0xcd,0xed,0x28,0x1b,0xdd, -0x66,0x38,0x40,0x5e,0x0b,0x13,0xaf,0x21,0xff,0x23,0xf1,0x5b,0xcd,0x32,0x43, -0x00,0x87,0x3d,0x10,0xc6,0x6e,0xe5,0x67,0xdc,0x9f,0x44,0x12,0x94,0xb4,0x76, -0xbd,0xd9,0x4c,0x53,0x12,0x1c,0x2e,0x2c,0x09,0x66,0x41,0x83,0x6c,0xee,0x68, -0x98,0x38,0xd2,0xc8,0x32,0xa3,0x42,0xcf,0x1c,0xfd,0x60,0x6c,0x5d,0x4b,0x4b, -0x6c,0xb8,0xf3,0x7e,0xc8,0x93,0x0a,0x68,0x66,0x14,0x3b,0x39,0x73,0x82,0xfe, -0x86,0x3c,0x3d,0xb3,0xb5,0x42,0xec,0x4c,0xc6,0xe6,0xdd,0x7e,0xd7,0xb4,0x5d, -0xeb,0x6d,0x8c,0x9e,0x29,0x95,0x99,0xb6,0x95,0x5b,0xc0,0xdd,0x46,0xdf,0xdc, -0xf2,0x1c,0x3d,0x80,0xeb,0x14,0x3d,0xd9,0x4a,0xb4,0x6f,0x3e,0x79,0xca,0x7f, -0xbc,0x27,0x47,0x90,0x86,0x55,0xfa,0x27,0xf5,0x35,0x3d,0x1d,0xc4,0xa8,0x55, -0x31,0x8f,0x3a,0x76,0x8d,0x98,0x50,0xa3,0x11,0x91,0x1c,0xb0,0xa8,0x06,0xf9, -0x22,0xb1,0xca,0x20,0x49,0xaa,0xe1,0x4d,0x41,0xf1,0x21,0xcc,0x25,0x45,0x33, -0x4f,0x2f,0x3a,0x48,0x70,0xbb }; + 0x30, 0x82, 0x05, 0xb5, 0x30, 0x82, 0x04, 0x9d, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x11, 0x00, 0xc9, 0xce, 0x10, 0xbc, 0x5e, 0xcf, 0xf2, 0xfd, + 0xa6, 0x37, 0xb8, 0x51, 0xf1, 0xe4, 0xb9, 0x30, 0x30, 0x0d, 0x06, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, + 0x7a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, + 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, + 0x02, 0x56, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, + 0x13, 0x07, 0x48, 0x65, 0x72, 0x6e, 0x64, 0x6f, 0x6e, 0x31, 0x21, 0x30, + 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x20, 0x53, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x20, 0x4c, 0x2e, 0x4c, 0x2e, 0x43, 0x2e, 0x31, 0x29, 0x30, 0x27, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x20, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x20, 0x53, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x20, 0x4f, 0x56, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, + 0x41, 0x20, 0x32, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x38, 0x30, 0x33, 0x30, + 0x36, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x30, + 0x30, 0x36, 0x30, 0x37, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, + 0x81, 0xc8, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, + 0x02, 0x55, 0x53, 0x31, 0x0e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x04, 0x11, + 0x13, 0x05, 0x35, 0x35, 0x31, 0x31, 0x34, 0x31, 0x0b, 0x30, 0x09, 0x06, + 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x4d, 0x4e, 0x31, 0x13, 0x30, 0x11, + 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0a, 0x53, 0x61, 0x69, 0x6e, 0x74, + 0x20, 0x50, 0x61, 0x75, 0x6c, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x04, 0x09, 0x13, 0x07, 0x53, 0x74, 0x65, 0x20, 0x31, 0x32, 0x30, 0x31, + 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x09, 0x13, 0x0f, 0x37, 0x30, + 0x30, 0x20, 0x52, 0x61, 0x79, 0x6d, 0x6f, 0x6e, 0x64, 0x20, 0x41, 0x76, + 0x65, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, + 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x31, + 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x02, 0x49, 0x54, + 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x18, 0x53, + 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x4c, 0x69, 0x6e, 0x6b, 0x20, 0x53, + 0x53, 0x4c, 0x20, 0x57, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, 0x31, + 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x2a, 0x2e, + 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x82, + 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, + 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc2, 0x91, 0x35, 0xc7, 0x67, + 0x32, 0xf1, 0x66, 0x12, 0x38, 0x79, 0xdb, 0x02, 0x11, 0x95, 0x89, 0x1b, + 0x4a, 0x6a, 0x63, 0x45, 0x35, 0x58, 0x1b, 0x57, 0x8d, 0xec, 0x19, 0x88, + 0xf5, 0xa3, 0x9e, 0x6b, 0xdb, 0x07, 0xfb, 0x6e, 0x29, 0xe9, 0xa9, 0x14, + 0x07, 0x8c, 0x3a, 0xc1, 0xd7, 0x88, 0xcc, 0xe4, 0x55, 0x79, 0x6e, 0x97, + 0xe9, 0x93, 0x88, 0x9a, 0x89, 0xf9, 0x31, 0x0f, 0x91, 0x61, 0xc2, 0x9c, + 0xae, 0x59, 0x25, 0x93, 0x9a, 0xc8, 0xf9, 0x28, 0x7a, 0x0f, 0x0f, 0x89, + 0x9a, 0xda, 0x46, 0xbe, 0xb2, 0xdc, 0x90, 0x5b, 0xd8, 0x87, 0xda, 0xda, + 0xce, 0x70, 0x70, 0x95, 0x43, 0x51, 0xa0, 0x21, 0x22, 0x54, 0xab, 0xa7, + 0x09, 0xe1, 0x81, 0x09, 0x8c, 0x00, 0x15, 0x30, 0x5a, 0xa7, 0x61, 0x77, + 0xba, 0x48, 0x91, 0xc6, 0x94, 0x90, 0xdd, 0x1a, 0xf4, 0x3f, 0xa6, 0x8a, + 0xb4, 0x2f, 0x98, 0x16, 0x0d, 0x96, 0x9f, 0x0c, 0x96, 0x01, 0x15, 0xbc, + 0x74, 0x7e, 0x5c, 0x4e, 0xe3, 0x95, 0xae, 0x00, 0xf5, 0x5b, 0x88, 0x0f, + 0xef, 0x7c, 0x1f, 0xab, 0x22, 0xfe, 0x95, 0x42, 0x1a, 0xbd, 0xee, 0x23, + 0xca, 0x5b, 0x7f, 0x4a, 0xb0, 0xbe, 0x15, 0x65, 0xe2, 0xce, 0x02, 0xc4, + 0xf6, 0xb8, 0xf3, 0xd6, 0x7e, 0x75, 0x5e, 0x63, 0x47, 0x5d, 0xc1, 0xca, + 0xc3, 0xc4, 0x4a, 0xf5, 0x4d, 0x66, 0x34, 0x03, 0xf8, 0xf4, 0x54, 0x7d, + 0x6b, 0x54, 0x2f, 0x17, 0x7c, 0x39, 0x13, 0x78, 0x09, 0x9e, 0xd0, 0x9c, + 0x51, 0x02, 0x11, 0x9d, 0xa7, 0x53, 0x60, 0xdd, 0x62, 0x2b, 0xee, 0xb0, + 0xd1, 0xf2, 0x1a, 0x5c, 0xdc, 0xa7, 0x58, 0xc2, 0xfa, 0x29, 0xcf, 0xf3, + 0xc9, 0xe9, 0xae, 0xe8, 0x70, 0x60, 0x99, 0xc7, 0x30, 0xdd, 0x1c, 0xda, + 0x32, 0xc0, 0x45, 0xa5, 0x48, 0xc5, 0x22, 0x29, 0x0c, 0x74, 0x25, 0x02, + 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0xe5, 0x30, 0x82, 0x01, 0xe1, + 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, + 0x14, 0x20, 0x33, 0xcd, 0xb7, 0x61, 0xf6, 0xa5, 0x86, 0x4f, 0xdc, 0xc9, + 0xd7, 0x73, 0x6a, 0xbc, 0x0a, 0x51, 0x65, 0x98, 0xec, 0x30, 0x1d, 0x06, + 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xff, 0x4c, 0x0f, 0x46, + 0xb8, 0x3c, 0x5b, 0x72, 0xe4, 0x10, 0x96, 0xbb, 0xa7, 0xbc, 0x91, 0xa2, + 0x63, 0xf6, 0x81, 0x0a, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, + 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x0c, 0x06, 0x03, + 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2b, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, + 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x20, + 0x04, 0x6e, 0x30, 0x6c, 0x30, 0x60, 0x06, 0x0c, 0x2b, 0x06, 0x01, 0x04, + 0x01, 0x86, 0x0e, 0x01, 0x02, 0x01, 0x03, 0x01, 0x30, 0x50, 0x30, 0x4e, + 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x42, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x65, 0x67, 0x61, + 0x6c, 0x2f, 0x53, 0x53, 0x4c, 0x2d, 0x6c, 0x65, 0x67, 0x61, 0x6c, 0x2d, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2d, 0x63, + 0x70, 0x73, 0x2e, 0x6a, 0x73, 0x70, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, + 0x0c, 0x01, 0x02, 0x02, 0x30, 0x49, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, + 0x42, 0x30, 0x40, 0x30, 0x3e, 0xa0, 0x3c, 0xa0, 0x3a, 0x86, 0x38, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x6e, 0x65, + 0x74, 0x73, 0x6f, 0x6c, 0x73, 0x73, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x6f, 0x6c, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x4f, 0x56, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x43, 0x41, 0x32, 0x2e, 0x63, 0x72, 0x6c, 0x30, 0x7b, 0x06, 0x08, 0x2b, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, 0x6f, 0x30, 0x6d, 0x30, + 0x44, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, + 0x38, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x74, 0x2e, + 0x6e, 0x65, 0x74, 0x73, 0x6f, 0x6c, 0x73, 0x73, 0x6c, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x6f, 0x6c, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4f, 0x56, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x43, 0x41, 0x32, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x25, 0x06, + 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x19, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x6e, + 0x65, 0x74, 0x73, 0x6f, 0x6c, 0x73, 0x73, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, + 0x30, 0x23, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x1c, 0x30, 0x1a, 0x82, + 0x0c, 0x2a, 0x2e, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, + 0x67, 0x82, 0x0a, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, + 0x67, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, + 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x58, 0x90, 0xa4, + 0x5b, 0x56, 0x5f, 0xf6, 0xab, 0x28, 0x6b, 0xc8, 0x17, 0xe6, 0x48, 0x51, + 0x38, 0x51, 0xea, 0xc2, 0x16, 0x07, 0x88, 0x32, 0xa0, 0x75, 0x17, 0xef, + 0xc3, 0xc3, 0x19, 0xce, 0xfb, 0xc9, 0x98, 0x2c, 0x1f, 0x16, 0x94, 0x41, + 0xa0, 0x46, 0xc5, 0x0d, 0x7e, 0x90, 0x40, 0x24, 0xd2, 0xb1, 0xf4, 0xc8, + 0x51, 0x43, 0x21, 0x54, 0xdb, 0xed, 0x47, 0x21, 0x97, 0x37, 0x11, 0xc9, + 0x22, 0xe5, 0xcc, 0xe1, 0x64, 0x5e, 0x3a, 0xd0, 0xbf, 0x95, 0x4a, 0xe9, + 0x3a, 0x32, 0x05, 0xca, 0x9d, 0xb4, 0x8c, 0x7e, 0xce, 0x31, 0x54, 0xb0, + 0x5f, 0xf5, 0xcf, 0xef, 0x59, 0x71, 0x7b, 0x5d, 0xaf, 0xc0, 0x76, 0xe2, + 0xdb, 0x89, 0x03, 0x25, 0x94, 0xc4, 0x55, 0xd4, 0xf8, 0xac, 0xe1, 0xbb, + 0x12, 0xc1, 0x24, 0x97, 0xd0, 0xfb, 0x17, 0x64, 0xae, 0x80, 0xc9, 0x3b, + 0xff, 0x16, 0x20, 0xfd, 0x65, 0x0c, 0x34, 0xdf, 0x7b, 0x11, 0xf6, 0x37, + 0xcb, 0x5c, 0xec, 0x98, 0xef, 0xab, 0xd3, 0x60, 0xaf, 0x6e, 0x1b, 0x0d, + 0x1b, 0xfd, 0xc1, 0x43, 0xf0, 0x8d, 0xb5, 0x44, 0xdf, 0xcc, 0xc3, 0xe7, + 0x6e, 0xb6, 0x51, 0x9e, 0x8b, 0x77, 0x5c, 0x1a, 0x8b, 0xbd, 0xb4, 0xa4, + 0x28, 0xf8, 0x01, 0x41, 0xc5, 0xa1, 0xc0, 0x64, 0x0a, 0xe0, 0x6f, 0x32, + 0x30, 0x2c, 0x06, 0x2a, 0xc4, 0x76, 0x0b, 0x95, 0x8b, 0xbf, 0x14, 0x59, + 0x16, 0xb3, 0xd1, 0xee, 0xc9, 0xef, 0x71, 0xd5, 0x5a, 0x26, 0xb4, 0xb0, + 0xba, 0x86, 0x1f, 0x41, 0x13, 0xd8, 0xff, 0x96, 0x51, 0x7b, 0x2e, 0x8f, + 0x85, 0x21, 0x60, 0xcd, 0x8f, 0x47, 0xe2, 0x48, 0x44, 0x07, 0x38, 0x29, + 0xdd, 0x0a, 0x3a, 0x01, 0xd8, 0x2c, 0x37, 0x8d, 0xc3, 0x0e, 0x68, 0xc5, + 0xd4, 0x24, 0x86, 0x2b, 0x05, 0x8f, 0xf5, 0x08, 0xd7, 0x46, 0x73, 0x59, + 0xb2 +}; /* Battle.Net's cert */ static const BYTE battlenet[] = { 0x30,0x82,0x03,0xd8,0x30,0x82,0x02,0xc0,0xa0,0x03,0x02,0x01,0x02,0x02,0x10, @@ -2889,6 +2912,415 @@ static const BYTE chain31_1[] = { 0x43,0x08,0xe5,0x78,0x2b,0x95,0xf3,0x75,0xb6,0x88,0xf0,0x6b,0x5c,0x5b,0x50, 0x04,0x91,0x3b,0x89,0x5a,0x60,0x1f,0xfc,0x36,0x53,0x32,0x36,0x0a,0x4d,0x03, 0x2c,0xd7 }; +/* Microsoft Root Certificate Authority 2010 */ +static const BYTE chain32_1[] = { +0x30,0x82,0x05,0xed,0x30,0x82,0x03,0xd5,0xa0,0x03,0x02,0x01,0x02,0x02,0x10, +0x28,0xcc,0x3a,0x25,0xbf,0xba,0x44,0xac,0x44,0x9a,0x9b,0x58,0x6b,0x43,0x39, +0xaa,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05, +0x00,0x30,0x81,0x88,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, +0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61, +0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55, +0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c, +0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66, +0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x32, +0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73, +0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66, +0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79, +0x20,0x32,0x30,0x31,0x30,0x30,0x1e,0x17,0x0d,0x31,0x30,0x30,0x36,0x32,0x33, +0x32,0x31,0x35,0x37,0x32,0x34,0x5a,0x17,0x0d,0x33,0x35,0x30,0x36,0x32,0x33, +0x32,0x32,0x30,0x34,0x30,0x31,0x5a,0x30,0x81,0x88,0x31,0x0b,0x30,0x09,0x06, +0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55, +0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31, +0x10,0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f, +0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69, +0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61, +0x74,0x69,0x6f,0x6e,0x31,0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29, +0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20, +0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74, +0x68,0x6f,0x72,0x69,0x74,0x79,0x20,0x32,0x30,0x31,0x30,0x30,0x82,0x02,0x22, +0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00, +0x03,0x82,0x02,0x0f,0x00,0x30,0x82,0x02,0x0a,0x02,0x82,0x02,0x01,0x00,0xb9, +0x08,0x9e,0x28,0xe4,0xe4,0xec,0x06,0x4e,0x50,0x68,0xb3,0x41,0xc5,0x7b,0xeb, +0xae,0xb6,0x8e,0xaf,0x81,0xba,0x22,0x44,0x1f,0x65,0x34,0x69,0x4c,0xbe,0x70, +0x40,0x17,0xf2,0x16,0x7b,0xe2,0x79,0xfd,0x86,0xed,0x0d,0x39,0xf4,0x1b,0xa8, +0xad,0x92,0x90,0x1e,0xcb,0x3d,0x76,0x8f,0x5a,0xd9,0xb5,0x91,0x10,0x2e,0x3c, +0x05,0x8d,0x8a,0x6d,0x24,0x54,0xe7,0x1f,0xed,0x56,0xad,0x83,0xb4,0x50,0x9c, +0x15,0xa5,0x17,0x74,0x88,0x59,0x20,0xfc,0x08,0xc5,0x84,0x76,0xd3,0x68,0xd4, +0x6f,0x28,0x78,0xce,0x5c,0xb8,0xf3,0x50,0x90,0x44,0xff,0xe3,0x63,0x5f,0xbe, +0xa1,0x9a,0x2c,0x96,0x15,0x04,0xd6,0x07,0xfe,0x1e,0x84,0x21,0xe0,0x42,0x31, +0x11,0xc4,0x28,0x36,0x94,0xcf,0x50,0xa4,0x62,0x9e,0xc9,0xd6,0xab,0x71,0x00, +0xb2,0x5b,0x0c,0xe6,0x96,0xd4,0x0a,0x24,0x96,0xf5,0xff,0xc6,0xd5,0xb7,0x1b, +0xd7,0xcb,0xb7,0x21,0x62,0xaf,0x12,0xdc,0xa1,0x5d,0x37,0xe3,0x1a,0xfb,0x1a, +0x46,0x98,0xc0,0x9b,0xc0,0xe7,0x63,0x1f,0x2a,0x08,0x93,0x02,0x7e,0x1e,0x6a, +0x8e,0xf2,0x9f,0x18,0x89,0xe4,0x22,0x85,0xa2,0xb1,0x84,0x57,0x40,0xff,0xf5, +0x0e,0xd8,0x6f,0x9c,0xed,0xe2,0x45,0x31,0x01,0xcd,0x17,0xe9,0x7f,0xb0,0x81, +0x45,0xe3,0xaa,0x21,0x40,0x26,0xa1,0x72,0xaa,0xa7,0x4f,0x3c,0x01,0x05,0x7e, +0xee,0x83,0x58,0xb1,0x5e,0x06,0x63,0x99,0x62,0x91,0x78,0x82,0xb7,0x0d,0x93, +0x0c,0x24,0x6a,0xb4,0x1b,0xdb,0x27,0xec,0x5f,0x95,0x04,0x3f,0x93,0x4a,0x30, +0xf5,0x97,0x18,0xb3,0xa7,0xf9,0x19,0xa7,0x93,0x33,0x1d,0x01,0xc8,0xdb,0x22, +0x52,0x5c,0xd7,0x25,0xc9,0x46,0xf9,0xa2,0xfb,0x87,0x59,0x43,0xbe,0x9b,0x62, +0xb1,0x8d,0x2d,0x86,0x44,0x1a,0x46,0xac,0x78,0x61,0x7e,0x30,0x09,0xfa,0xae, +0x89,0xc4,0x41,0x2a,0x22,0x66,0x03,0x91,0x39,0x45,0x9c,0xc7,0x8b,0x0c,0xa8, +0xca,0x0d,0x2f,0xfb,0x52,0xea,0x0c,0xf7,0x63,0x33,0x23,0x9d,0xfe,0xb0,0x1f, +0xad,0x67,0xd6,0xa7,0x50,0x03,0xc6,0x04,0x70,0x63,0xb5,0x2c,0xb1,0x86,0x5a, +0x43,0xb7,0xfb,0xae,0xf9,0x6e,0x29,0x6e,0x21,0x21,0x41,0x26,0x06,0x8c,0xc9, +0xc3,0xee,0xb0,0xc2,0x85,0x93,0xa1,0xb9,0x85,0xd9,0xe6,0x32,0x6c,0x4b,0x4c, +0x3f,0xd6,0x5d,0xa3,0xe5,0xb5,0x9d,0x77,0xc3,0x9c,0xc0,0x55,0xb7,0x74,0x00, +0xe3,0xb8,0x38,0xab,0x83,0x97,0x50,0xe1,0x9a,0x42,0x24,0x1d,0xc6,0xc0,0xa3, +0x30,0xd1,0x1a,0x5a,0xc8,0x52,0x34,0xf7,0x73,0xf1,0xc7,0x18,0x1f,0x33,0xad, +0x7a,0xec,0xcb,0x41,0x60,0xf3,0x23,0x94,0x20,0xc2,0x48,0x45,0xac,0x5c,0x51, +0xc6,0x2e,0x80,0xc2,0xe2,0x77,0x15,0xbd,0x85,0x87,0xed,0x36,0x9d,0x96,0x91, +0xee,0x00,0xb5,0xa3,0x70,0xec,0x9f,0xe3,0x8d,0x80,0x68,0x83,0x76,0xba,0xaf, +0x5d,0x70,0x52,0x22,0x16,0xe2,0x66,0xfb,0xba,0xb3,0xc5,0xc2,0xf7,0x3e,0x2f, +0x77,0xa6,0xca,0xde,0xc1,0xa6,0xc6,0x48,0x4c,0xc3,0x37,0x51,0x23,0xd3,0x27, +0xd7,0xb8,0x4e,0x70,0x96,0xf0,0xa1,0x44,0x76,0xaf,0x78,0xcf,0x9a,0xe1,0x66, +0x13,0x02,0x03,0x01,0x00,0x01,0xa3,0x51,0x30,0x4f,0x30,0x0b,0x06,0x03,0x55, +0x1d,0x0f,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13, +0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1d,0x06,0x03,0x55, +0x1d,0x0e,0x04,0x16,0x04,0x14,0xd5,0xf6,0x56,0xcb,0x8f,0xe8,0xa2,0x5c,0x62, +0x68,0xd1,0x3d,0x94,0x90,0x5b,0xd7,0xce,0x9a,0x18,0xc4,0x30,0x10,0x06,0x09, +0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x15,0x01,0x04,0x03,0x02,0x01,0x00,0x30, +0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x03, +0x82,0x02,0x01,0x00,0xac,0xa5,0x96,0x8c,0xbf,0xbb,0xae,0xa6,0xf6,0xd7,0x71, +0x87,0x43,0x31,0x56,0x88,0xfd,0x1c,0x32,0x71,0x5b,0x35,0xb7,0xd4,0xf0,0x91, +0xf2,0xaf,0x37,0xe2,0x14,0xf1,0xf3,0x02,0x26,0x05,0x3e,0x16,0x14,0x7f,0x14, +0xba,0xb8,0x4f,0xfb,0x89,0xb2,0xb2,0xe7,0xd4,0x09,0xcc,0x6d,0xb9,0x5b,0x3b, +0x64,0x65,0x70,0x66,0xb7,0xf2,0xb1,0x5a,0xdf,0x1a,0x02,0xf3,0xf5,0x51,0xb8, +0x67,0x6d,0x79,0xf3,0xbf,0x56,0x7b,0xe4,0x84,0xb9,0x2b,0x1e,0x9b,0x40,0x9c, +0x26,0x34,0xf9,0x47,0x18,0x98,0x69,0xd8,0x1c,0xd7,0xb6,0xd1,0xbf,0x8f,0x61, +0xc2,0x67,0xc4,0xb5,0xef,0x60,0x43,0x8e,0x10,0x1b,0x36,0x49,0xe4,0x20,0xca, +0xad,0xa7,0xc1,0xb1,0x27,0x65,0x09,0xf8,0xcd,0xf5,0x5b,0x2a,0xd0,0x84,0x33, +0xf3,0xef,0x1f,0xf2,0xf5,0x9c,0x0b,0x58,0x93,0x37,0xa0,0x75,0xa0,0xde,0x72, +0xde,0x6c,0x75,0x2a,0x66,0x22,0xf5,0x8c,0x06,0x30,0x56,0x9f,0x40,0xb9,0x30, +0xaa,0x40,0x77,0x15,0x82,0xd7,0x8b,0xec,0xc0,0xd3,0xb2,0xbd,0x83,0xc5,0x77, +0x0c,0x1e,0xae,0xaf,0x19,0x53,0xa0,0x4d,0x79,0x71,0x9f,0x0f,0xaf,0x30,0xce, +0x67,0xf9,0xd6,0x2c,0xcc,0x22,0x41,0x7a,0x07,0xf2,0x97,0x42,0x18,0xce,0x59, +0x79,0x10,0x55,0xde,0x6f,0x10,0xe4,0xb8,0xda,0x83,0x66,0x40,0x16,0x09,0x68, +0x23,0x5b,0x97,0x2e,0x26,0x9a,0x02,0xbb,0x57,0x8c,0xc5,0xb8,0xba,0x69,0x62, +0x32,0x80,0x89,0x9e,0xa1,0xfd,0xc0,0x92,0x7c,0x7b,0x2b,0x33,0x19,0x84,0x2a, +0x63,0xc5,0x00,0x68,0x62,0xfa,0x9f,0x47,0x8d,0x99,0x7a,0x45,0x3a,0xa7,0xe9, +0xed,0xee,0x69,0x42,0xb5,0xf3,0x81,0x9b,0x47,0x56,0x10,0x7b,0xfc,0x70,0x36, +0x84,0x18,0x73,0xea,0xef,0xf9,0x97,0x4d,0x9e,0x33,0x23,0xdd,0x26,0x0b,0xba, +0x2a,0xb7,0x3f,0x44,0xdc,0x83,0x27,0xff,0xbd,0x61,0x59,0x2b,0x11,0xb7,0xca, +0x4f,0xdb,0xc5,0x8b,0x0c,0x1c,0x31,0xae,0x32,0xf8,0xf8,0xb9,0x42,0xf7,0x7f, +0xdc,0x61,0x9a,0x76,0xb1,0x5a,0x04,0xe1,0x11,0x3d,0x66,0x45,0xb7,0x18,0x71, +0xbe,0xc9,0x24,0x85,0xd6,0xf3,0xd4,0xba,0x41,0x34,0x5d,0x12,0x2d,0x25,0xb9, +0x8d,0xa6,0x13,0x48,0x6d,0x4b,0xb0,0x07,0x7d,0x99,0x93,0x09,0x61,0x81,0x74, +0x57,0x26,0x8a,0xab,0x69,0xe3,0xe4,0xd9,0xc7,0x88,0xcc,0x24,0xd8,0xec,0x52, +0x24,0x5c,0x1e,0xbc,0x91,0x14,0xe2,0x96,0xde,0xeb,0x0a,0xda,0x9e,0xdd,0x5f, +0xb3,0x5b,0xdb,0xd4,0x82,0xec,0xc6,0x20,0x50,0x87,0x25,0x40,0x3a,0xfb,0xc7, +0xee,0xcd,0xfe,0x33,0xe5,0x6e,0xc3,0x84,0x09,0x55,0x03,0x25,0x39,0xc0,0xe9, +0x35,0x5d,0x65,0x31,0xa8,0xf6,0xbf,0xa0,0x09,0xcd,0x29,0xc7,0xb3,0x36,0x32, +0x2e,0xdc,0x95,0xf3,0x83,0xc1,0x5a,0xcf,0x8b,0x8d,0xf6,0xea,0xb3,0x21,0xf8, +0xa4,0xed,0x1e,0x31,0x0e,0xb6,0x4c,0x11,0xab,0x60,0x0b,0xa4,0x12,0x23,0x22, +0x17,0xa3,0x36,0x64,0x82,0x91,0x04,0x12,0xe0,0xab,0x6f,0x1e,0xcb,0x50,0x05, +0x61,0xb4,0x40,0xff,0x59,0x86,0x71,0xd1,0xd5,0x33,0x69,0x7c,0xa9,0x73,0x8a, +0x38,0xd7,0x64,0x0c,0xf1,0x69 }; +/* Microsoft Code Signing PCA 2010 */ +static const BYTE chain32_2[] = { +0x30,0x82,0x06,0x70,0x30,0x82,0x04,0x58,0xa0,0x03,0x02,0x01,0x02,0x02,0x0a, +0x61,0x0c,0x52,0x4c,0x00,0x00,0x00,0x00,0x00,0x03,0x30,0x0d,0x06,0x09,0x2a, +0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x30,0x81,0x88,0x31,0x0b, +0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11, +0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69,0x6e,0x67,0x74, +0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65, +0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13, +0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70, +0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x32,0x30,0x30,0x06,0x03,0x55,0x04, +0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x52,0x6f, +0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20, +0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79,0x20,0x32,0x30,0x31,0x30,0x30, +0x1e,0x17,0x0d,0x31,0x30,0x30,0x37,0x30,0x36,0x32,0x30,0x34,0x30,0x31,0x37, +0x5a,0x17,0x0d,0x32,0x35,0x30,0x37,0x30,0x36,0x32,0x30,0x35,0x30,0x31,0x37, +0x5a,0x30,0x7e,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55, +0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61,0x73, +0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55,0x04, +0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06, +0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74, +0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x28,0x30, +0x26,0x06,0x03,0x55,0x04,0x03,0x13,0x1f,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, +0x66,0x74,0x20,0x43,0x6f,0x64,0x65,0x20,0x53,0x69,0x67,0x6e,0x69,0x6e,0x67, +0x20,0x50,0x43,0x41,0x20,0x32,0x30,0x31,0x30,0x30,0x82,0x01,0x22,0x30,0x0d, +0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82, +0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,0x82,0x01,0x01,0x00,0xe9,0x0e,0x64, +0x50,0x79,0x67,0xb5,0xc4,0xe3,0xfd,0x09,0x00,0x4c,0x9e,0x94,0xac,0xf7,0x56, +0x68,0xea,0x44,0xd8,0xcf,0xc5,0x58,0x4f,0xa9,0xa5,0x76,0x7c,0x6d,0x45,0xba, +0xd3,0x39,0x92,0xb4,0xa4,0x1e,0xf9,0xf9,0x65,0x82,0xe4,0x17,0xd2,0x8f,0xfd, +0x44,0x9c,0x08,0xe8,0x65,0x93,0xce,0x2c,0x55,0x84,0xbf,0x7d,0x08,0xe3,0x2e, +0x2b,0xa8,0x41,0x2b,0x18,0xb7,0xa2,0x4b,0x6e,0x49,0x4c,0x6b,0x15,0x07,0xde, +0xd1,0xd2,0xc2,0x89,0x1e,0x71,0x94,0xcd,0xb5,0x7f,0x4b,0xb4,0xaf,0x08,0xd8, +0xcc,0x88,0xd6,0x6b,0x17,0x94,0x3a,0x93,0xce,0x26,0x3f,0xec,0xe6,0xfe,0x34, +0x98,0x57,0xd5,0x1d,0x5d,0x49,0xf6,0xb2,0x2a,0x2e,0xd5,0x85,0xbb,0x59,0x3f, +0xf8,0x90,0xb4,0x2b,0x83,0x74,0xca,0x2b,0xb3,0x3b,0x46,0xe3,0xf0,0x46,0x49, +0xc1,0x17,0x66,0x54,0xc9,0x1c,0xbd,0x1d,0xc4,0x55,0x62,0x57,0x72,0xf8,0x67, +0xb9,0x25,0x20,0x34,0xde,0x5d,0xa6,0xa5,0x95,0x5e,0xab,0x28,0x80,0xcd,0xd5, +0xb2,0x9e,0xe5,0x03,0xb5,0x63,0xd3,0xb2,0x14,0xc8,0xc1,0xc8,0x8a,0x26,0x0a, +0x59,0x7f,0x07,0xec,0xff,0x0e,0xed,0x80,0x12,0x35,0x4c,0x12,0xa6,0xbe,0x52, +0x5b,0xf5,0xa6,0xda,0xe0,0x8b,0x0b,0x48,0x77,0xd6,0x85,0x47,0xd5,0x10,0xb9, +0xc6,0xe8,0xaa,0xee,0x8b,0x6a,0x2d,0x05,0x5c,0x60,0xc6,0xb4,0x2a,0x5b,0x9c, +0x23,0x1c,0x5f,0x45,0xe3,0x1a,0x14,0x1e,0x6f,0x37,0xcb,0x19,0x33,0x80,0x6a, +0x89,0x4d,0xa3,0x6a,0x66,0x63,0x78,0x93,0xd5,0x30,0xcf,0x95,0x1f,0x02,0x03, +0x01,0x00,0x01,0xa3,0x82,0x01,0xe3,0x30,0x82,0x01,0xdf,0x30,0x10,0x06,0x09, +0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x15,0x01,0x04,0x03,0x02,0x01,0x00,0x30, +0x1d,0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0xe6,0xfc,0x5f,0x7b,0xbb, +0x22,0x00,0x58,0xe4,0x72,0x4e,0xb5,0xf4,0x21,0x74,0x23,0x32,0xe6,0xef,0xac, +0x30,0x19,0x06,0x09,0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x04,0x0c, +0x1e,0x0a,0x00,0x53,0x00,0x75,0x00,0x62,0x00,0x43,0x00,0x41,0x30,0x0b,0x06, +0x03,0x55,0x1d,0x0f,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x0f,0x06,0x03,0x55, +0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1f,0x06, +0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xd5,0xf6,0x56,0xcb,0x8f, +0xe8,0xa2,0x5c,0x62,0x68,0xd1,0x3d,0x94,0x90,0x5b,0xd7,0xce,0x9a,0x18,0xc4, +0x30,0x56,0x06,0x03,0x55,0x1d,0x1f,0x04,0x4f,0x30,0x4d,0x30,0x4b,0xa0,0x49, +0xa0,0x47,0x86,0x45,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x63,0x72,0x6c,0x2e, +0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x70, +0x6b,0x69,0x2f,0x63,0x72,0x6c,0x2f,0x70,0x72,0x6f,0x64,0x75,0x63,0x74,0x73, +0x2f,0x4d,0x69,0x63,0x52,0x6f,0x6f,0x43,0x65,0x72,0x41,0x75,0x74,0x5f,0x32, +0x30,0x31,0x30,0x2d,0x30,0x36,0x2d,0x32,0x33,0x2e,0x63,0x72,0x6c,0x30,0x5a, +0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x4e,0x30,0x4c,0x30, +0x4a,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x3e,0x68,0x74, +0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x6d,0x69,0x63,0x72,0x6f,0x73, +0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x70,0x6b,0x69,0x2f,0x63,0x65,0x72, +0x74,0x73,0x2f,0x4d,0x69,0x63,0x52,0x6f,0x6f,0x43,0x65,0x72,0x41,0x75,0x74, +0x5f,0x32,0x30,0x31,0x30,0x2d,0x30,0x36,0x2d,0x32,0x33,0x2e,0x63,0x72,0x74, +0x30,0x81,0x9d,0x06,0x03,0x55,0x1d,0x20,0x04,0x81,0x95,0x30,0x81,0x92,0x30, +0x81,0x8f,0x06,0x09,0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x2e,0x03,0x30,0x81, +0x81,0x30,0x3d,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x31, +0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x6d,0x69,0x63,0x72, +0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x50,0x4b,0x49,0x2f,0x64, +0x6f,0x63,0x73,0x2f,0x43,0x50,0x53,0x2f,0x64,0x65,0x66,0x61,0x75,0x6c,0x74, +0x2e,0x68,0x74,0x6d,0x30,0x40,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x02, +0x02,0x30,0x34,0x1e,0x32,0x20,0x1d,0x00,0x4c,0x00,0x65,0x00,0x67,0x00,0x61, +0x00,0x6c,0x00,0x5f,0x00,0x50,0x00,0x6f,0x00,0x6c,0x00,0x69,0x00,0x63,0x00, +0x79,0x00,0x5f,0x00,0x53,0x00,0x74,0x00,0x61,0x00,0x74,0x00,0x65,0x00,0x6d, +0x00,0x65,0x00,0x6e,0x00,0x74,0x00,0x2e,0x20,0x1d,0x30,0x0d,0x06,0x09,0x2a, +0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x03,0x82,0x02,0x01,0x00, +0x1a,0x74,0xef,0x57,0x4f,0x29,0x7b,0xc4,0x16,0x85,0x78,0xb8,0x50,0xd3,0x22, +0xfc,0x09,0x9d,0xac,0x82,0x97,0xf8,0x34,0xff,0x2a,0x2c,0x97,0x95,0x12,0xe5, +0xe4,0xbf,0xcf,0xbf,0x93,0xc8,0xe3,0x34,0xa9,0xdb,0x81,0xb8,0xdc,0x1e,0x00, +0xbe,0xd2,0x35,0x6f,0xaf,0xe5,0x7f,0x79,0x95,0x77,0xe5,0x02,0xd4,0xf1,0xeb, +0xd8,0xcd,0x4e,0x1e,0x1b,0x61,0xa2,0xc2,0x5a,0x23,0x1a,0xf0,0x8c,0xa8,0x62, +0x51,0x45,0x67,0x08,0xe3,0x3f,0x3c,0x1e,0x93,0xf8,0x30,0x85,0x17,0xc8,0x39, +0x40,0xa6,0xd7,0x0e,0xb3,0x21,0x29,0xe5,0xa5,0xa1,0x69,0x8c,0x22,0x93,0xcc, +0x74,0x98,0xe7,0xa1,0x47,0x43,0xf2,0x53,0xac,0xc0,0x0f,0x30,0x69,0x7f,0xfe, +0xd2,0x25,0x20,0x6d,0x6f,0x61,0xd3,0xdf,0x07,0xd5,0xd9,0x72,0x00,0x2c,0x69, +0x86,0x76,0x3d,0x51,0xdb,0xa6,0x39,0x48,0xc9,0x37,0x61,0x6d,0x07,0xdd,0x53, +0x19,0xcb,0xa7,0xd6,0x61,0xc2,0xbf,0xe2,0x83,0xab,0x0f,0xe0,0x6b,0x9b,0x95, +0xd6,0x7d,0x28,0x51,0xb0,0x89,0x4a,0x51,0xa4,0x9a,0x6c,0xc8,0xb7,0x1f,0x4a, +0x1a,0x0e,0x69,0xa9,0xd7,0xdc,0xc1,0x7e,0xd1,0x49,0x70,0xaa,0xb6,0xad,0xbb, +0x72,0x47,0x63,0x17,0xfa,0xa6,0xd6,0xa2,0xa6,0x86,0xec,0xa8,0x10,0x44,0x9b, +0x63,0xb6,0xb2,0x69,0x89,0x06,0xc7,0x46,0x86,0x7a,0x18,0x3f,0xe8,0xc5,0x1d, +0x21,0xd5,0x7b,0xf9,0x02,0x23,0x2d,0xc5,0x41,0xcb,0xbf,0x1d,0x4c,0xc8,0x16, +0xef,0xb1,0x9c,0x7f,0xfc,0x22,0x4b,0x49,0x8a,0x6e,0x15,0xe3,0xa6,0x7f,0x76, +0x5b,0xd1,0x53,0x79,0x91,0x85,0x9d,0xd5,0xd2,0xdb,0x3d,0x73,0x35,0xf3,0x3c, +0xae,0x54,0xb2,0x52,0x47,0x6a,0xc0,0xaa,0x13,0x95,0xd2,0x8e,0x11,0xda,0x99, +0x67,0x5e,0x32,0x8c,0xfb,0x37,0x85,0xd1,0xdc,0x75,0x85,0x9c,0x87,0xc6,0x5a, +0x57,0x85,0xc2,0xbf,0xdd,0x0d,0x8f,0x8c,0x9b,0x2d,0xeb,0xb4,0xee,0xcf,0x27, +0xd3,0xb5,0x5e,0x69,0xfa,0xa4,0x16,0x04,0x01,0xa7,0x24,0x67,0x73,0xcf,0x4d, +0x4f,0xb6,0xde,0x05,0x56,0x97,0x7a,0xf7,0xe9,0x52,0x4d,0xf4,0x77,0x05,0x4f, +0x85,0xc6,0xd8,0x0b,0xf1,0x8e,0xed,0x42,0x09,0xd1,0x0d,0x76,0xe3,0x23,0x56, +0x78,0x22,0x26,0x36,0xbe,0xca,0xb1,0x8c,0x6e,0xaa,0x1d,0xe4,0x85,0xda,0x47, +0x33,0x62,0x8f,0xa4,0xc9,0x91,0x33,0x5f,0x71,0x1e,0x40,0xaf,0x98,0x65,0xc9, +0x22,0xe8,0x42,0x21,0x25,0x8a,0x1c,0x2d,0x60,0xd9,0x37,0x89,0x41,0x89,0x2a, +0x16,0x0f,0xd7,0x61,0x3c,0x94,0x68,0x60,0x52,0xef,0xd6,0x47,0x99,0xa0,0x80, +0x40,0xee,0x15,0x81,0x77,0x3e,0x9c,0xe0,0x53,0x18,0x1a,0x50,0x1d,0x38,0x95, +0x9b,0x1e,0x66,0x33,0x13,0x27,0x39,0x17,0x78,0x87,0x36,0xce,0x4e,0xc3,0x5f, +0xb2,0xf5,0x3d,0x47,0x53,0xb6,0xe0,0xe5,0xdb,0x0b,0x61,0x3d,0x2a,0xd7,0x92, +0x2c,0xce,0x37,0x5a,0x3e,0x40,0x42,0x31,0xa4,0x1f,0x10,0x08,0xc2,0x56,0x9c, +0xbf,0x24,0x5d,0x51,0x02,0x9d,0x6a,0x79,0xd2,0x17,0xd3,0xda,0xc1,0x94,0x8e, +0x07,0x7b,0x25,0x71,0x44,0xab,0x06,0x6a,0xe6,0xd4,0xc6,0xdf,0x23,0x9a,0x96, +0x75,0xc5 }; +/* Microsoft Corporation (expired) */ +static const BYTE chain32_3[] = { +0x30,0x82,0x04,0xfe,0x30,0x82,0x03,0xe6,0xa0,0x03,0x02,0x01,0x02,0x02,0x13, +0x33,0x00,0x00,0x02,0xcf,0x6d,0x2c,0xc5,0x7c,0xaa,0x65,0xa6,0xd8,0x00,0x00, +0x00,0x00,0x02,0xcf,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, +0x01,0x0b,0x05,0x00,0x30,0x7e,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06, +0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a, +0x57,0x61,0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06, +0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e, +0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73, +0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e, +0x31,0x28,0x30,0x26,0x06,0x03,0x55,0x04,0x03,0x13,0x1f,0x4d,0x69,0x63,0x72, +0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x64,0x65,0x20,0x53,0x69,0x67,0x6e, +0x69,0x6e,0x67,0x20,0x50,0x43,0x41,0x20,0x32,0x30,0x31,0x30,0x30,0x1e,0x17, +0x0d,0x31,0x39,0x30,0x35,0x30,0x32,0x32,0x31,0x32,0x35,0x34,0x32,0x5a,0x17, +0x0d,0x32,0x30,0x30,0x35,0x30,0x32,0x32,0x31,0x32,0x35,0x34,0x32,0x5a,0x30, +0x74,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31, +0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69, +0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13, +0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06,0x03,0x55, +0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43, +0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x1e,0x30,0x1c,0x06, +0x03,0x55,0x04,0x03,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74, +0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x30,0x82,0x01, +0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05, +0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,0x82,0x01,0x01,0x00, +0xb9,0x5a,0xf3,0xb5,0x5d,0x58,0xf9,0x43,0x0f,0x95,0x01,0x79,0xfa,0x74,0xe5, +0xb0,0xca,0xb5,0x38,0xf0,0x92,0xca,0xec,0x9b,0x99,0x42,0x1d,0x3a,0xea,0xb5, +0x8f,0x75,0x75,0x83,0xa9,0x1b,0x36,0xff,0x40,0x96,0x8e,0xd7,0x75,0x0a,0xd1, +0x96,0xae,0xc7,0xb3,0x77,0x12,0x39,0x82,0xd9,0xee,0x48,0x75,0x3d,0x47,0xad, +0x53,0x39,0x3c,0x69,0xd1,0xca,0xd8,0xf0,0x3f,0x21,0x5a,0x4c,0x3a,0xe8,0x28, +0x67,0xc3,0x7d,0x20,0x53,0x4b,0x9c,0x8b,0xbc,0x93,0xf9,0x20,0x46,0xf0,0x50, +0x82,0xca,0x6f,0x6a,0x4e,0x56,0xf1,0xd4,0x43,0xae,0xd8,0xe9,0xdb,0xbe,0x7c, +0x77,0x7d,0x46,0x73,0x03,0x3a,0x64,0xe9,0xf6,0x2d,0xcb,0x25,0x51,0x0d,0x90, +0xc9,0x16,0x59,0x29,0x0c,0x15,0x20,0x63,0xa8,0xb8,0x4f,0x70,0x24,0x9d,0x01, +0xe5,0x69,0x94,0x49,0xc9,0xd6,0x58,0xa8,0x9b,0x89,0xb8,0x2f,0xe0,0x6e,0x1b, +0xa7,0xcc,0x9d,0x75,0x08,0xa6,0xc8,0x31,0x65,0x0f,0xa3,0xed,0xbd,0xd6,0xc6, +0x93,0x8c,0x66,0x22,0xbf,0x48,0x57,0x1d,0x8c,0xa1,0xc1,0xe6,0xad,0x90,0x81, +0x29,0x2b,0x8a,0x62,0xf4,0xc2,0xa1,0xdb,0xc8,0xc1,0x79,0x23,0x74,0x37,0x08, +0x92,0x65,0xe3,0x57,0x01,0xe4,0x4f,0xa1,0x0a,0xf5,0x68,0x96,0xd6,0x09,0x80, +0x4a,0x05,0xdc,0xae,0x30,0xd7,0xb1,0x5a,0xfb,0x1d,0xf9,0x84,0xde,0x92,0xcb, +0xf2,0xc0,0xf8,0xea,0x26,0x6e,0xd3,0x73,0x7e,0xc5,0x66,0xa5,0x05,0xac,0xc4, +0xeb,0x10,0xda,0x0c,0x5c,0x7c,0x36,0x99,0x9c,0x59,0x89,0xc6,0x94,0x47,0xf6, +0xbb,0x02,0x03,0x01,0x00,0x01,0xa3,0x82,0x01,0x7d,0x30,0x82,0x01,0x79,0x30, +0x1f,0x06,0x03,0x55,0x1d,0x25,0x04,0x18,0x30,0x16,0x06,0x0a,0x2b,0x06,0x01, +0x04,0x01,0x82,0x37,0x3d,0x06,0x01,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07, +0x03,0x03,0x30,0x1d,0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x37,0xf3, +0x4d,0xec,0x4d,0xaf,0x2c,0x04,0x31,0xa9,0x10,0x88,0x0b,0x58,0xc0,0x6f,0x03, +0xbc,0x55,0x08,0x30,0x54,0x06,0x03,0x55,0x1d,0x11,0x04,0x4d,0x30,0x4b,0xa4, +0x49,0x30,0x47,0x31,0x2d,0x30,0x2b,0x06,0x03,0x55,0x04,0x0b,0x13,0x24,0x4d, +0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x49,0x72,0x65,0x6c,0x61,0x6e, +0x64,0x20,0x4f,0x70,0x65,0x72,0x61,0x74,0x69,0x6f,0x6e,0x73,0x20,0x4c,0x69, +0x6d,0x69,0x74,0x65,0x64,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x05,0x13, +0x0d,0x32,0x33,0x30,0x38,0x36,0x35,0x2b,0x34,0x35,0x34,0x32,0x34,0x34,0x30, +0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xe6,0xfc,0x5f, +0x7b,0xbb,0x22,0x00,0x58,0xe4,0x72,0x4e,0xb5,0xf4,0x21,0x74,0x23,0x32,0xe6, +0xef,0xac,0x30,0x56,0x06,0x03,0x55,0x1d,0x1f,0x04,0x4f,0x30,0x4d,0x30,0x4b, +0xa0,0x49,0xa0,0x47,0x86,0x45,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x63,0x72, +0x6c,0x2e,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d, +0x2f,0x70,0x6b,0x69,0x2f,0x63,0x72,0x6c,0x2f,0x70,0x72,0x6f,0x64,0x75,0x63, +0x74,0x73,0x2f,0x4d,0x69,0x63,0x43,0x6f,0x64,0x53,0x69,0x67,0x50,0x43,0x41, +0x5f,0x32,0x30,0x31,0x30,0x2d,0x30,0x37,0x2d,0x30,0x36,0x2e,0x63,0x72,0x6c, +0x30,0x5a,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x4e,0x30, +0x4c,0x30,0x4a,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x3e, +0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x6d,0x69,0x63,0x72, +0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x70,0x6b,0x69,0x2f,0x63, +0x65,0x72,0x74,0x73,0x2f,0x4d,0x69,0x63,0x43,0x6f,0x64,0x53,0x69,0x67,0x50, +0x43,0x41,0x5f,0x32,0x30,0x31,0x30,0x2d,0x30,0x37,0x2d,0x30,0x36,0x2e,0x63, +0x72,0x74,0x30,0x0c,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,0x30, +0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05, +0x00,0x03,0x82,0x01,0x01,0x00,0xaa,0x30,0x8f,0x08,0x74,0xb1,0x28,0x88,0x0a, +0x81,0x0c,0xcc,0x38,0xea,0xb1,0xc0,0x47,0x9a,0x7d,0xf3,0x19,0x35,0xa6,0xe8, +0x8b,0xe9,0x16,0x04,0xe4,0xc3,0x32,0xe1,0x29,0xf7,0xcc,0xb8,0xf0,0xc6,0xc3, +0x02,0xd5,0xb0,0x8d,0x0b,0x41,0xfe,0x5c,0xa9,0x03,0x86,0x25,0xf5,0x24,0x9f, +0xb0,0x04,0xc4,0x69,0x0a,0x27,0x94,0x04,0xb2,0x09,0xdc,0x19,0xaf,0xbb,0x01, +0x8b,0x92,0xe4,0xd8,0x72,0x04,0x07,0x72,0x81,0xd3,0x89,0xca,0xd7,0x79,0x98, +0x41,0xe5,0xa0,0x29,0xfb,0x95,0x91,0xd9,0xf8,0x8c,0x40,0x23,0x70,0x9a,0xb2, +0xf6,0xcb,0x0a,0x75,0x0b,0xbd,0x1c,0x72,0xd7,0xff,0x98,0x20,0x01,0xde,0xc0, +0xcd,0xd0,0xd3,0xa5,0xff,0x6b,0x0c,0x8b,0xf9,0x85,0x69,0x22,0x15,0x09,0xd7, +0x4e,0xf2,0xc1,0xe9,0xd4,0x78,0xa7,0xd1,0xe3,0x46,0xf6,0x3d,0xa9,0x06,0x66, +0x11,0xa3,0x9e,0x2f,0xef,0xe6,0xd3,0xc5,0x80,0x29,0xc8,0xfa,0xd3,0xb7,0x98, +0x0d,0xdc,0xa4,0xce,0x84,0x68,0xeb,0x9b,0xfb,0x14,0x83,0x28,0x6d,0x22,0x57, +0x9a,0x46,0xbe,0x37,0x71,0xc4,0xec,0xed,0x38,0x8f,0x4d,0x6e,0x13,0x54,0x39, +0x87,0xc6,0xf4,0x1e,0x41,0xdf,0xba,0x87,0x28,0xda,0xc2,0xc0,0x02,0xa5,0x80, +0x52,0x3c,0xbd,0x9a,0xe2,0x66,0xc0,0x5e,0xc3,0x56,0xe8,0x65,0x1d,0xcc,0xd4, +0xec,0xf5,0x4d,0x05,0xae,0xf3,0x9b,0x96,0x7b,0xf2,0xa9,0x3b,0xae,0xe0,0xbb, +0x3b,0x42,0x9b,0xec,0x20,0xba,0xea,0x1c,0x6d,0xf4,0x6a,0x24,0x8f,0x31,0x01, +0x3c,0x8a,0x0a,0x58,0x61,0x67,0x58 }; +/* Microsoft Root Certificate Authority 2011 */ +static const BYTE chain33_1[] = { +0x30,0x82,0x05,0xed,0x30,0x82,0x03,0xd5,0xa0,0x03,0x02,0x01,0x02,0x02,0x10, +0x3f,0x8b,0xc8,0xb5,0xfc,0x9f,0xb2,0x96,0x43,0xb5,0x69,0xd6,0x6c,0x42,0xe1, +0x44,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05, +0x00,0x30,0x81,0x88,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, +0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61, +0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55, +0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c, +0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66, +0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x32, +0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73, +0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66, +0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79, +0x20,0x32,0x30,0x31,0x31,0x30,0x1e,0x17,0x0d,0x31,0x31,0x30,0x33,0x32,0x32, +0x32,0x32,0x30,0x35,0x32,0x38,0x5a,0x17,0x0d,0x33,0x36,0x30,0x33,0x32,0x32, +0x32,0x32,0x31,0x33,0x30,0x34,0x5a,0x30,0x81,0x88,0x31,0x0b,0x30,0x09,0x06, +0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55, +0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31, +0x10,0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f, +0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69, +0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61, +0x74,0x69,0x6f,0x6e,0x31,0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29, +0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20, +0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74, +0x68,0x6f,0x72,0x69,0x74,0x79,0x20,0x32,0x30,0x31,0x31,0x30,0x82,0x02,0x22, +0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00, +0x03,0x82,0x02,0x0f,0x00,0x30,0x82,0x02,0x0a,0x02,0x82,0x02,0x01,0x00,0xb2, +0x80,0x41,0xaa,0x35,0x38,0x4d,0x13,0x72,0x32,0x68,0x22,0x4d,0xb8,0xb2,0xf1, +0xff,0xd5,0x52,0xbc,0x6c,0xc7,0xf5,0xd2,0x4a,0x8c,0x36,0xee,0xd1,0xc2,0x5c, +0x7e,0x8c,0x8a,0xae,0xaf,0x13,0x28,0x6f,0xc0,0x73,0xe3,0x3a,0xce,0xd0,0x25, +0xa8,0x5a,0x3a,0x6d,0xef,0xa8,0xb8,0x59,0xab,0x13,0x23,0x68,0xcd,0x0c,0x29, +0x87,0xd1,0x6f,0x80,0x5c,0x8f,0x44,0x7f,0x5d,0x90,0x01,0x52,0x58,0xac,0x51, +0xc5,0x5f,0x2a,0x87,0xdc,0xdc,0xd8,0x0a,0x1d,0xc1,0x03,0xb9,0x7b,0xb0,0x56, +0xe8,0xa3,0xde,0x64,0x61,0xc2,0x9e,0xf8,0xf3,0x7c,0xb9,0xec,0x0d,0xb5,0x54, +0xfe,0x4c,0xb6,0x65,0x4f,0x88,0xf0,0x9c,0x48,0x99,0x0c,0x42,0x0b,0x09,0x7c, +0x31,0x59,0x17,0x79,0x06,0x78,0x28,0x8d,0x89,0x3a,0x4c,0x03,0x25,0xbe,0x71, +0x6a,0x5c,0x0b,0xe7,0x84,0x60,0xa4,0x99,0x22,0xe3,0xd2,0xaf,0x84,0xa4,0xa7, +0xfb,0xd1,0x98,0xed,0x0c,0xa9,0xde,0x94,0x89,0xe1,0x0e,0xa0,0xdc,0xc0,0xce, +0x99,0x3d,0xea,0x08,0x52,0xbb,0x56,0x79,0xe4,0x1f,0x84,0xba,0x1e,0xb8,0xb4, +0xc4,0x49,0x5c,0x4f,0x31,0x4b,0x87,0xdd,0xdd,0x05,0x67,0x26,0x99,0x80,0xe0, +0x71,0x11,0xa3,0xb8,0xa5,0x41,0xe2,0xa4,0x53,0xb9,0xf7,0x32,0x29,0x83,0x0c, +0x13,0xbf,0x36,0x5e,0x04,0xb3,0x4b,0x43,0x47,0x2f,0x6b,0xe2,0x91,0x1e,0xd3, +0x98,0x4f,0xdd,0x42,0x07,0xc8,0xe8,0x1d,0x12,0xfc,0x99,0xa9,0x6b,0x3e,0x92, +0x7e,0xc8,0xd6,0x69,0x3a,0xfc,0x64,0xbd,0xb6,0x09,0x9d,0xca,0xfd,0x0c,0x0b, +0xa2,0x9b,0x77,0x60,0x4b,0x03,0x94,0xa4,0x30,0x69,0x12,0xd6,0x42,0x2d,0xc1, +0x41,0x4c,0xca,0xdc,0xaa,0xfd,0x8f,0x5b,0x83,0x46,0x9a,0xd9,0xfc,0xb1,0xd1, +0xe3,0xb3,0xc9,0x7f,0x48,0x7a,0xcd,0x24,0xf0,0x41,0x8f,0x5c,0x74,0xd0,0xac, +0xb0,0x10,0x20,0x06,0x49,0xb7,0xc7,0x2d,0x21,0xc8,0x57,0xe3,0xd0,0x86,0xf3, +0x03,0x68,0xfb,0xd0,0xce,0x71,0xc1,0x89,0x99,0x4a,0x64,0x01,0x6c,0xfd,0xec, +0x30,0x91,0xcf,0x41,0x3c,0x92,0xc7,0xe5,0xba,0x86,0x1d,0x61,0x84,0xc7,0x5f, +0x83,0x39,0x62,0xae,0xb4,0x92,0x2f,0x47,0xf3,0x0b,0xf8,0x55,0xeb,0xa0,0x1f, +0x59,0xd0,0xbb,0x74,0x9b,0x1e,0xd0,0x76,0xe6,0xf2,0xe9,0x06,0xd7,0x10,0xe8, +0xfa,0x64,0xde,0x69,0xc6,0x35,0x96,0x88,0x02,0xf0,0x46,0xb8,0x3f,0x27,0x99, +0x6f,0xcb,0x71,0x89,0x29,0x35,0xf7,0x48,0x16,0x02,0x35,0x8f,0xd5,0x79,0x7c, +0x4d,0x02,0xcf,0x5f,0xeb,0x8a,0x83,0x4f,0x45,0x71,0x88,0xf9,0xa9,0x0d,0x4e, +0x72,0xe9,0xc2,0x9c,0x07,0xcf,0x49,0x1b,0x4e,0x04,0x0e,0x63,0x51,0x8c,0x5e, +0xd8,0x00,0xc1,0x55,0x2c,0xb6,0xc6,0xe0,0xc2,0x65,0x4e,0xc9,0x34,0x39,0xf5, +0x9c,0xb3,0xc4,0x7e,0xe8,0x61,0x6e,0x13,0x5f,0x15,0xc4,0x5f,0xd9,0x7e,0xed, +0x1d,0xce,0xee,0x44,0xec,0xcb,0x2e,0x86,0xb1,0xec,0x38,0xf6,0x70,0xed,0xab, +0x5c,0x13,0xc1,0xd9,0x0f,0x0d,0xc7,0x80,0xb2,0x55,0xed,0x34,0xf7,0xac,0x9b, +0xe4,0xc3,0xda,0xe7,0x47,0x3c,0xa6,0xb5,0x8f,0x31,0xdf,0xc5,0x4b,0xaf,0xeb, +0xf1,0x02,0x03,0x01,0x00,0x01,0xa3,0x51,0x30,0x4f,0x30,0x0b,0x06,0x03,0x55, +0x1d,0x0f,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13, +0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1d,0x06,0x03,0x55, +0x1d,0x0e,0x04,0x16,0x04,0x14,0x72,0x2d,0x3a,0x02,0x31,0x90,0x43,0xb9,0x14, +0x05,0x4e,0xe1,0xea,0xa7,0xc7,0x31,0xd1,0x23,0x89,0x34,0x30,0x10,0x06,0x09, +0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x15,0x01,0x04,0x03,0x02,0x01,0x00,0x30, +0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x03, +0x82,0x02,0x01,0x00,0x7f,0x72,0xcf,0x0f,0xb7,0xc5,0x15,0xdb,0x9b,0xc0,0x49, +0xca,0x26,0x5b,0xfe,0x9e,0x13,0xe6,0xd3,0xf0,0xd2,0xdb,0x97,0x5f,0xf2,0x4b, +0x3f,0x4d,0xb3,0xae,0x19,0xae,0xed,0xd7,0x97,0xa0,0xac,0xef,0xa9,0x3a,0xa3, +0xc2,0x41,0xb0,0xe5,0xb8,0x91,0x9e,0x13,0x81,0x24,0x03,0xe6,0x09,0xfd,0x3f, +0x57,0x40,0x39,0x21,0x24,0x56,0xd1,0x10,0x2f,0x4b,0x40,0xa9,0x36,0x86,0x4b, +0xb4,0x53,0x57,0x9a,0xfb,0xf1,0x7e,0x89,0x8f,0x11,0xfe,0x18,0x6c,0x51,0xaa, +0xe8,0xed,0x09,0x95,0xb5,0xe5,0x71,0xc9,0xa1,0xe9,0x87,0x75,0xa6,0x15,0x7f, +0xc9,0x7e,0x37,0x54,0x5e,0x74,0x93,0xc5,0xc3,0x67,0xcc,0x0d,0x4f,0x6b,0xa8, +0x17,0x0c,0x6d,0x08,0x92,0x7e,0x8b,0xdd,0x81,0xaa,0x2d,0x70,0x21,0xc3,0x3d, +0x06,0x14,0xbb,0xbf,0x24,0x5e,0xa7,0x84,0xd7,0x3f,0x0f,0x21,0x22,0xbd,0x4b, +0x00,0x06,0xdb,0x97,0x1c,0xd8,0x5e,0xd4,0xc5,0x0b,0x5c,0x87,0x6e,0x50,0xa4, +0xe8,0xc3,0x38,0xa4,0xfb,0xcb,0x2c,0xc5,0x92,0x66,0x9b,0x85,0x5e,0xcb,0x7a, +0x6c,0x93,0x7c,0x80,0x29,0x58,0x5b,0x57,0xb5,0x40,0x69,0xba,0x08,0x79,0xa6, +0x64,0x62,0x15,0x9d,0x87,0x96,0x45,0xb5,0x66,0x23,0x20,0x03,0x8b,0x1c,0x73, +0xa0,0xd3,0xa2,0x79,0x33,0xe0,0x50,0x59,0x86,0xdb,0x2f,0xe5,0x02,0x25,0xea, +0x73,0x2a,0x9f,0x00,0x14,0xc8,0x36,0xc7,0x92,0x3b,0xe9,0x4e,0x00,0xec,0xd8, +0x56,0x09,0xb9,0x33,0x49,0x12,0xd2,0x54,0x0b,0x01,0xab,0xac,0x47,0xb6,0x91, +0x29,0x7d,0x4c,0xb4,0x75,0x80,0x52,0x01,0xe8,0xca,0x82,0xf6,0x9f,0xcc,0xac, +0x9c,0x8f,0x17,0xea,0x2f,0x26,0xb0,0xab,0x72,0xac,0x0b,0xfe,0x9e,0x51,0x1e, +0xc7,0x43,0x55,0x67,0x4f,0x51,0xb3,0x57,0xd6,0xb6,0xec,0xee,0x52,0xb7,0x3a, +0xe9,0x4e,0xe1,0xd7,0x81,0x88,0xbc,0x4f,0x8e,0x75,0xbb,0x4b,0xa8,0xf0,0x35, +0xaa,0x26,0xd4,0x67,0x67,0x49,0xb2,0x70,0x4c,0x3b,0x93,0xdc,0x1d,0xdf,0x78, +0x90,0x86,0x72,0xb2,0x38,0xa4,0xd1,0xdc,0x92,0x4d,0xc9,0x58,0xeb,0x2b,0x12, +0x5c,0xd4,0x3b,0xae,0x8c,0x6b,0xb0,0x83,0xe5,0x01,0x3f,0xf8,0x09,0x32,0xf6, +0x93,0x35,0x34,0x22,0xaf,0xdd,0x37,0x0d,0x77,0x09,0x80,0x2b,0xcd,0x48,0x00, +0xf1,0x8c,0x99,0x19,0x47,0x05,0x01,0xe9,0xd1,0xbf,0xd1,0x4e,0xd0,0xe6,0x28, +0x43,0x37,0x99,0xa4,0x0a,0x4a,0x08,0xd9,0x9a,0x71,0x73,0xd2,0xaa,0xcd,0x31, +0x13,0x63,0x76,0xa1,0x37,0x6f,0x92,0x38,0x1e,0x7d,0x12,0x3c,0x66,0x32,0xe7, +0xcb,0x6d,0xe1,0xfc,0x52,0x89,0xdd,0xca,0xd6,0x66,0x05,0x9a,0x96,0x61,0xbe, +0xa2,0x28,0xc7,0x1c,0xa3,0xa7,0x36,0x50,0x3c,0x3a,0xa4,0xdf,0x4a,0x6e,0xe6, +0x87,0x3b,0xce,0xeb,0xf0,0xe0,0x81,0x37,0x9d,0x13,0x3c,0x52,0x8e,0xbd,0xb9, +0x1d,0x34,0xc6,0x1d,0xd5,0x0a,0x6a,0x3d,0x98,0x29,0x70,0x8c,0x89,0x2a,0xd1, +0xab,0x82,0x10,0x48,0x1f,0xdc,0xf4,0xef,0xa5,0xc5,0xbb,0x55,0x1a,0x38,0x63, +0x84,0x4e,0xb7,0x6c,0xad,0x95,0x54,0xec,0x65,0x22,0x10,0x49,0x17,0xb8,0xc0, +0x1e,0xc7,0x0f,0xac,0x54,0x47 }; typedef struct _CONST_DATA_BLOB { @@ -2936,7 +3368,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine, ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, certArray->rgBlob[i].pbData, certArray->rgBlob[i].cbData, CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "Chain %d: adding cert %d failed: %08x\n", + ok(ret, "Chain %ld: adding cert %ld failed: %08lx\n", testIndex, i, GetLastError()); } } @@ -2944,7 +3376,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine, X509_ASN_ENCODING, certArray->rgBlob[certArray->cBlob - 1].pbData, certArray->rgBlob[certArray->cBlob - 1].cbData, CERT_STORE_ADD_ALWAYS, &endCert); - ok(ret, "Chain %d: adding end cert failed: %08x\n", + ok(ret, "Chain %ld: adding end cert failed: %08lx\n", testIndex, GetLastError()); if (ret) { @@ -2955,10 +3387,10 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine, ok(SystemTimeToFileTime(checkTime, &fileTime), "SystemTimeToFileTime failed for day %d, month %d, year %d\n", checkTime->wDay, checkTime->wMonth, checkTime->wYear); - ret = pCertGetCertificateChain(engine, endCert, &fileTime, + ret = CertGetCertificateChain(engine, endCert, &fileTime, includeStore ? store : NULL, &chainPara, flags, NULL, &chain); todo_wine_if (todo & TODO_CHAIN) - ok(ret, "Chain %d: CertGetCertificateChain failed: %08x\n", + ok(ret, "Chain %ld: CertGetCertificateChain failed: %08lx\n", testIndex, GetLastError()); CertFreeCertificateContext(endCert); } @@ -2980,27 +3412,27 @@ static void checkElementStatus(const CERT_TRUST_STATUS *expected, { if (got->dwErrorStatus == expected->dwErrorStatus) ok(got->dwErrorStatus == expected->dwErrorStatus, - "%s[%d], element [%d,%d]: expected error %08x, got %08x\n", + "%s[%ld], element [%ld,%ld]: expected error %08lx, got %08lx\n", testName, testIndex, chainIndex, elementIndex, expected->dwErrorStatus, got->dwErrorStatus); else todo_wine_if (todo & TODO_ERROR) ok(got->dwErrorStatus == expected->dwErrorStatus || broken((got->dwErrorStatus & ~ignore->dwErrorStatus) == (expected->dwErrorStatus & ~ignore->dwErrorStatus)), - "%s[%d], element [%d,%d]: expected error %08x, got %08x. %08x is " + "%s[%ld], element [%ld,%ld]: expected error %08lx, got %08lx. %08x is " "expected if no valid root certificate is available.\n", testName, testIndex, chainIndex, elementIndex, expected->dwErrorStatus, got->dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT); if (got->dwInfoStatus == expected->dwInfoStatus) ok(got->dwInfoStatus == expected->dwInfoStatus, - "%s[%d], element [%d,%d]: expected info %08x, got %08x\n", + "%s[%ld], element [%ld,%ld]: expected info %08lx, got %08lx\n", testName, testIndex, chainIndex, elementIndex, expected->dwInfoStatus, got->dwInfoStatus); else todo_wine_if (todo & TODO_INFO) ok(got->dwInfoStatus == expected->dwInfoStatus || broken((got->dwInfoStatus & ~ignore->dwInfoStatus) == (expected->dwInfoStatus & ~ignore->dwInfoStatus)), - "%s[%d], element [%d,%d]: expected info %08x, got %08x\n", + "%s[%ld], element [%ld,%ld]: expected info %08lx, got %08lx\n", testName, testIndex, chainIndex, elementIndex, expected->dwInfoStatus, got->dwInfoStatus); } @@ -3012,7 +3444,7 @@ static void checkSimpleChainStatus(const CERT_SIMPLE_CHAIN *simpleChain, { todo_wine_if (todo & TODO_ELEMENTS) ok(simpleChain->cElement == simpleChainStatus->cElement, - "%s[%d]: expected %d elements, got %d\n", testName, testIndex, + "%s[%ld]: expected %ld elements, got %ld\n", testName, testIndex, simpleChainStatus->cElement, simpleChain->cElement); if (simpleChain->cElement == simpleChainStatus->cElement) { @@ -3038,7 +3470,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain, DWORD testIndex) { ok(chain->cChain == chainStatus->cChain, - "%s[%d]: expected %d simple chains, got %d\n", testName, testIndex, + "%s[%ld]: expected %ld simple chains, got %ld\n", testName, testIndex, chainStatus->cChain, chain->cChain); todo_wine_if (todo & TODO_ERROR && chain->TrustStatus.dwErrorStatus != chainStatus->status.dwErrorStatus) @@ -3048,7 +3480,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain, ~chainStatus->statusToIgnore.dwErrorStatus) == (chainStatus->status.dwErrorStatus & ~chainStatus->statusToIgnore.dwErrorStatus)), - "%s[%d]: expected error %08x, got %08x. %08x is expected if no valid " + "%s[%ld]: expected error %08lx, got %08lx. %08x is expected if no valid " "root certificate is available.\n", testName, testIndex, chainStatus->status.dwErrorStatus, chain->TrustStatus.dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT); @@ -3060,7 +3492,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain, ~chainStatus->statusToIgnore.dwInfoStatus) == (chainStatus->status.dwInfoStatus & ~chainStatus->statusToIgnore.dwInfoStatus)), - "%s[%d]: expected info %08x, got %08x\n", + "%s[%ld]: expected info %08lx, got %08lx\n", testName, testIndex, chainStatus->status.dwInfoStatus, chain->TrustStatus.dwInfoStatus); if (chain->cChain == chainStatus->cChain) @@ -3086,6 +3518,8 @@ static SYSTEMTIME jun2013 = { 2013, 6, 5, 6, 0, 0, 0, 0 }; static SYSTEMTIME oct2016 = { 2016, 10, 6, 1, 0, 0, 0, 0 }; /* Wednesday, Nov 17, 2016 */ static SYSTEMTIME nov2016 = { 2016, 11, 3, 17, 0, 0, 0, 0 }; +/* Thursday, May 14, 2020 */ +static SYSTEMTIME may2020 = { 2020, 5, 4, 14, 0, 0, 0, 0 }; typedef struct _ChainCheck { @@ -3485,6 +3919,14 @@ static CONST_DATA_BLOB chain31[] = { { sizeof(chain0_0), chain0_0 }, { sizeof(chain31_1), chain31_1 }, }; +static CONST_DATA_BLOB chain32[] = { + { sizeof(chain32_1), chain32_1 }, + { sizeof(chain32_2), chain32_2 }, + { sizeof(chain32_3), chain32_3 }, +}; +static CONST_DATA_BLOB chain33[] = { + { sizeof(chain33_1), chain33_1 }, +}; static CONST_DATA_BLOB selfSignedChain[] = { { sizeof(selfSignedCert), selfSignedCert } }; @@ -3807,7 +4249,7 @@ static ChainCheck chainCheck[] = { { { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID, 0 }, - 1, googleSimpleStatus }, TODO_INFO, &oct2016 }, + 1, googleSimpleStatus }, TODO_INFO | TODO_ERROR, &oct2016 }, /* The stanford chain may or may not have its root trusted, so ignore the error */ { { ARRAY_SIZE(stanfordChain), stanfordChain }, @@ -3902,17 +4344,17 @@ static void testGetCertChain(void) if (0) { /* Crash on Vista */ - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, &chain); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Crash - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); - ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, &chain); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, @@ -3920,39 +4362,39 @@ static void testGetCertChain(void) if (0) { /* Crash on Vista */ - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } /* Crash - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); */ /* Tests with an invalid cert (one whose signature is bad) */ SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == CRYPT_E_ASN1_BADTAG /* Vista */, - "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError()); + "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == CRYPT_E_ASN1_BADTAG /* Vista */, - "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError()); + "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError()); para.cbSize = 0; SetLastError(0xdeadbeef); - ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == CRYPT_E_ASN1_BADTAG, /* Vista and higher */ - "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError()); + "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError()); CertFreeCertificateContext(cert); @@ -3972,47 +4414,47 @@ static void testGetCertChain(void) para.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND; para.RequestedUsage.Usage.rgpszUsageIdentifier = oids; para.RequestedUsage.Usage.cUsageIdentifier = 1; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError()); + ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE, "expected CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } oids[0] = oid_server_auth; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError()); + ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(!(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE), - "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE, got %x\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE, got %lx\n", chain->TrustStatus.dwErrorStatus); + CertFreeCertificateChain(chain); } oids[1] = one_two_three; para.RequestedUsage.Usage.cUsageIdentifier = 2; para.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError()); + ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE, "expected CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, ¶, + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError()); + ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError()); if (ret) { ok(!(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE), "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } CertCloseStore(store, 0); CertFreeCertificateContext(cert); @@ -4025,7 +4467,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheck[i].status, chainCheck[i].todo, "chainCheck", i); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } } chain = getChain(NULL, &opensslChainCheck.certs, 0, TRUE, &oct2007, @@ -4038,7 +4480,7 @@ static void testGetCertChain(void) ~incompleteOpensslChainCheck.status.statusToIgnore.dwErrorStatus) == (incompleteOpensslChainCheck.status.status.dwErrorStatus & ~incompleteOpensslChainCheck.status.statusToIgnore.dwErrorStatus)), - "unexpected chain error status %08x\n", + "unexpected chain error status %08lx\n", chain->TrustStatus.dwErrorStatus); if (opensslChainCheck.status.status.dwErrorStatus == chain->TrustStatus.dwErrorStatus) @@ -4048,7 +4490,7 @@ static void testGetCertChain(void) checkChainStatus(chain, &incompleteOpensslChainCheck.status, incompleteOpensslChainCheck.todo, "incompleteOpensslChainCheck", 0); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } for (i = 0; i < ARRAY_SIZE(chainCheckNoStore); i++) { @@ -4058,7 +4500,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheckNoStore[i].status, chainCheckNoStore[i].todo, "chainCheckNoStore", i); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } } chain = getChain(NULL, &chainCheckEmbeddedNull.certs, 0, TRUE, &oct2007, @@ -4071,7 +4513,7 @@ static void testGetCertChain(void) ~chainCheckEmbeddedNullBroken.status.statusToIgnore.dwErrorStatus) == (chainCheckEmbeddedNullBroken.status.status.dwErrorStatus & ~chainCheckEmbeddedNullBroken.status.statusToIgnore.dwErrorStatus)), - "unexpected chain error status %08x\n", + "unexpected chain error status %08lx\n", chain->TrustStatus.dwErrorStatus); if (chainCheckEmbeddedNull.status.status.dwErrorStatus == chain->TrustStatus.dwErrorStatus) @@ -4081,15 +4523,15 @@ static void testGetCertChain(void) checkChainStatus(chain, &chainCheckEmbeddedNullBroken.status, chainCheckEmbeddedNullBroken.todo, "chainCheckEmbeddedNullBroken", 0); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %u\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %lu\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, winehq_org, sizeof(winehq_org), CERT_STORE_ADD_ALWAYS, &cert); - ok(ret, "CertAddEncodedCertificateToStore failed: %u\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %lu\n", GetLastError()); oids[0] = oid_server_auth; memset(¶, 0, sizeof(para)); @@ -4100,77 +4542,79 @@ static void testGetCertChain(void) /* Pass store that does not contain all certs in chain. */ ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); + ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); - if(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_PARTIAL_CHAIN) { /* win2k */ - win_skip("winehq cert reported as partial chain, skipping its tests\n"); - pCertFreeCertificateChain(chain); - CertCloseStore(store, 0); - return; - } - - ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", + chain->TrustStatus.dwErrorStatus); todo_wine - ok(chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, "chain->TrustStatus.dwInfoStatus = %x\n", + ok(chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, "chain->TrustStatus.dwInfoStatus = %lx\n", chain->TrustStatus.dwInfoStatus); - ok(chain->cChain == 1, "chain->cChain = %d\n", chain->cChain); - ok(!chain->cLowerQualityChainContext, "chain->cLowerQualityChainContext = %x\n", chain->cLowerQualityChainContext); + ok(chain->cChain == 1, "chain->cChain = %ld\n", chain->cChain); + ok(!chain->cLowerQualityChainContext, "chain->cLowerQualityChainContext = %lx\n", chain->cLowerQualityChainContext); ok(!chain->rgpLowerQualityChainContext, "chain->rgpLowerQualityChainContext = %p\n", chain->rgpLowerQualityChainContext); simple_chain = *chain->rgpChain; - ok(simple_chain->cbSize == sizeof(*simple_chain), "simple_chain->cbSize = %u\n", simple_chain->cbSize); - ok(!simple_chain->TrustStatus.dwErrorStatus, "simple_chain->TrustStatus.dwErrorStatus = %x\n", + ok(simple_chain->cbSize == sizeof(*simple_chain), "simple_chain->cbSize = %lu\n", simple_chain->cbSize); + ok(simple_chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "simple_chain->TrustStatus.dwErrorStatus = %lx\n", simple_chain->TrustStatus.dwErrorStatus); todo_wine ok(simple_chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, - "simple_chain->TrustStatus.dwInfoStatus = %x\n", simple_chain->TrustStatus.dwInfoStatus); - ok(simple_chain->cElement == 3, "simple_chain->cElement = %u\n", simple_chain->cElement); + "simple_chain->TrustStatus.dwInfoStatus = %lx\n", simple_chain->TrustStatus.dwInfoStatus); + ok(simple_chain->cElement == 3, "simple_chain->cElement = %lu\n", simple_chain->cElement); for(i=0; i < simple_chain->cElement; i++) { chain_elem = simple_chain->rgpElement[i]; - ok(chain_elem->cbSize == sizeof(*chain_elem), "chain_elem->cbSize = %u\n", chain_elem->cbSize); - - ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %x\n", - chain_elem->TrustStatus.dwErrorStatus); - trace("info[%u] = %x\n", i, chain_elem->TrustStatus.dwInfoStatus); + ok(chain_elem->cbSize == sizeof(*chain_elem), "chain_elem->cbSize = %lu\n", chain_elem->cbSize); + if (!i || i == 1) + ok(chain_elem->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, + "chain_elem->TrustStatus.dwErrorStatus = %lx\n", chain_elem->TrustStatus.dwErrorStatus); + else + ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %lx\n", + chain_elem->TrustStatus.dwErrorStatus); + trace("info[%lu] = %lx\n", i, chain_elem->TrustStatus.dwInfoStatus); ok(chain_elem->pCertContext->dwCertEncodingType == CRYPT_ASN_ENCODING, - "chain_elem->pCertContext->dwCertEncodingType = %x\n", + "chain_elem->pCertContext->dwCertEncodingType = %lx\n", chain_elem->pCertContext->dwCertEncodingType); } ok(simple_chain->rgpElement[0]->pCertContext == cert, "simple_chain->rgpElement[0]->pCertContext != cert\n"); - test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Issuer, "US, GeoTrust Inc., GeoTrust Global CA"); - test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Subject, "US, \"GeoTrust, Inc.\", RapidSSL CA"); - test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Issuer, "US, GeoTrust Inc., GeoTrust Global CA"); - test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Subject, "US, GeoTrust Inc., GeoTrust Global CA"); + test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Issuer, + "US, New Jersey, Jersey City, The USERTRUST Network, USERTrust RSA Certification Authority"); + test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Subject, + "US, VA, Herndon, Network Solutions L.L.C., Network Solutions OV Server CA 2"); + test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Issuer, + "US, New Jersey, Jersey City, The USERTRUST Network, USERTrust RSA Certification Authority"); + test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Subject, + "US, New Jersey, Jersey City, The USERTRUST Network, USERTrust RSA Certification Authority"); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); /* Test revocation flags */ ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_END_CERT, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); - ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", + chain->TrustStatus.dwErrorStatus); + CertFreeCertificateChain(chain); ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); - ok(!chain->TrustStatus.dwErrorStatus - || broken(chain->TrustStatus.dwErrorStatus == CERT_TRUST_REVOCATION_STATUS_UNKNOWN), /* XP */ - "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, + "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus); + CertFreeCertificateChain(chain); ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); - ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); - pCertFreeCertificateChain(chain); + ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n", + chain->TrustStatus.dwErrorStatus); + CertFreeCertificateChain(chain); /* Test HCCE_LOCAL_MACHINE */ ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); - pCertFreeCertificateChain(chain); + ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError()); + CertFreeCertificateChain(chain); CertFreeCertificateContext(cert); CertCloseStore(store, 0); @@ -4191,11 +4635,11 @@ static void test_CERT_CHAIN_PARA_cbSize(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain0_0, sizeof(chain0_0), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, chain0_1, sizeof(chain0_1), CERT_STORE_ADD_ALWAYS, &cert); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); for (i = 0; i < sizeof(CERT_CHAIN_PARA) + 2; i++) { @@ -4204,10 +4648,10 @@ static void test_CERT_CHAIN_PARA_cbSize(void) SystemTimeToFileTime(&oct2007, &fileTime); para.cbSize = i; - ret = pCertGetCertificateChain(NULL, cert, &fileTime, + ret = CertGetCertificateChain(NULL, cert, &fileTime, NULL, ¶, 0, NULL, &chain); - ok(ret, "CertGetCertificateChain failed %u\n", GetLastError()); - pCertFreeCertificateChain(chain); + ok(ret, "CertGetCertificateChain failed %lu\n", GetLastError()); + CertFreeCertificateChain(chain); } CertFreeCertificateContext(cert); @@ -4274,17 +4718,17 @@ static const CERT_CHAIN_POLICY_STATUS badDateNestingStatus = static const ChainPolicyCheck ignoredBadDateNestingBasePolicyCheck = { { ARRAY_SIZE(chain2), chain2 }, - { 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS + { 0, 0, -1, -1, NULL}, NULL, 0 }; static const ChainPolicyCheck ignoredInvalidDateBasePolicyCheck = { { ARRAY_SIZE(googleChain), googleChain }, - { 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS + { 0, 0, -1, -1, NULL}, NULL, 0 }; static const ChainPolicyCheck ignoredInvalidUsageBasePolicyCheck = { { ARRAY_SIZE(chain15), chain15 }, - { 0, CERT_E_EXPIRED, 0, 1, NULL}, NULL, TODO_ERROR + { 0, 0, -1, -1, NULL}, NULL, 0 }; static const ChainPolicyCheck invalidUsageBasePolicyCheck = { @@ -4345,13 +4789,9 @@ static const ChainPolicyCheck googlePolicyCheckWithMatchingNameExpired = { { 0, CERT_E_EXPIRED, 0, 0, NULL}, NULL, 0 }; -/* Win98 sees the chain as expired, even though it isn't for the date tested */ -static const CERT_CHAIN_POLICY_STATUS expiredStatus = - { 0, CERT_E_EXPIRED, 0, 0, NULL }; - static const ChainPolicyCheck googlePolicyCheckWithMatchingName = { { ARRAY_SIZE(googleChain), googleChain }, - { 0, 0, -1, -1, NULL}, &expiredStatus, 0 + { 0, 0, -1, -1, NULL}, NULL, 0 }; /* Win98 does not trust the root of the OpenSSL chain or the Stanford chain */ @@ -4501,6 +4941,27 @@ static const ChainPolicyCheck basicConstraintsPolicyCheck[] = { { 0, 0, -1, -1, NULL }, NULL, 0 }, }; +static const CERT_CHAIN_POLICY_STATUS chain32BrokenStatus = + { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }; + +static const ChainPolicyCheck msRootPolicyCheck[] = { + { { ARRAY_SIZE(chain0), chain0 }, + { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, TODO_ELEMENTS }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, + { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 }, + { { ARRAY_SIZE(chain32), chain32 }, + { 0, 0, 0, 0, NULL }, &chain32BrokenStatus, 0 }, + { { ARRAY_SIZE(chain33), chain33 }, + { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 }, +}; + +static const ChainPolicyCheck msRootPolicyCheck_approot[] = { + { { ARRAY_SIZE(chain32), chain32 }, + { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, TODO_ELEMENTS }, + { { ARRAY_SIZE(chain33), chain33 }, + { 0, 0, 0, 0, NULL }, NULL, 0 }, +}; + static const char *num_to_str(WORD num) { static char buf[6]; @@ -4519,12 +4980,12 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, if (chain) { CERT_CHAIN_POLICY_STATUS policyStatus = { 0 }; - BOOL ret = pCertVerifyCertificateChainPolicy(policy, chain, para, + BOOL ret = CertVerifyCertificateChainPolicy(policy, chain, para, &policyStatus); if (check->todo & TODO_POLICY) todo_wine ok(ret, - "%s[%d](%s): CertVerifyCertificateChainPolicy failed: %08x\n", + "%s[%ld](%s): CertVerifyCertificateChainPolicy failed: %08lx\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, GetLastError()); @@ -4532,13 +4993,13 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, { if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) { - skip("%s[%d]: missing policy %s, skipping test\n", + skip("%s[%ld]: missing policy %s, skipping test\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); return; } - ok(ret, "%s[%d](%s): CertVerifyCertificateChainPolicy failed: %08x\n", + ok(ret, "%s[%ld](%s): CertVerifyCertificateChainPolicy failed: %08lx\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, GetLastError()); @@ -4550,24 +5011,24 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, broken(policyStatus.dwError == CERT_TRUST_NO_ERROR) || (check->brokenStatus && broken(policyStatus.dwError == check->brokenStatus->dwError)), - "%s[%d](%s): expected %08x, got %08x\n", + "%s[%ld](%s): expected %08lx, got %08lx\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, check->status.dwError, policyStatus.dwError); if (policyStatus.dwError != check->status.dwError) { - skip("%s[%d](%s): error %08x doesn't match expected %08x, not checking indexes\n", + skip("%s[%ld](%s): error %08lx doesn't match expected %08lx, not checking indexes\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, policyStatus.dwError, check->status.dwError); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); return; } todo_wine_if (check->todo & TODO_CHAINS) ok(policyStatus.lChainIndex == check->status.lChainIndex || (check->brokenStatus && broken(policyStatus.lChainIndex == check->brokenStatus->lChainIndex)), - "%s[%d](%s): expected %d, got %d\n", + "%s[%ld](%s): expected %ld, got %ld\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, check->status.lChainIndex, policyStatus.lChainIndex); @@ -4575,12 +5036,12 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, ok(policyStatus.lElementIndex == check->status.lElementIndex || (check->brokenStatus && broken(policyStatus.lElementIndex == check->brokenStatus->lElementIndex)), - "%s[%d](%s): expected %d, got %d\n", + "%s[%ld](%s): expected %ld, got %ld\n", testName, testIndex, IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, check->status.lElementIndex, policyStatus.lElementIndex); } - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); } } @@ -4610,7 +5071,8 @@ static void check_base_policy(void) CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_BASE, NULL, ignoredBadDateNestingBasePolicyCheck, &oct2007, &policyPara); - policyPara.dwFlags = CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; + policyPara.dwFlags = CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG | + CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_BASE, NULL, ignoredInvalidDateBasePolicyCheck, &oct2007, &policyPara); policyPara.dwFlags = CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG | @@ -4653,7 +5115,7 @@ static void check_authenticode_policy(void) epochStart.wYear = 1601; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_AUTHENTICODE, NULL, ignoredUnknownCAPolicyCheck, &epochStart, &policyPara); - policyPara.dwFlags = CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; + policyPara.dwFlags |= CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_AUTHENTICODE, NULL, ignoredInvalidDateBasePolicyCheck, &oct2007, &policyPara); } @@ -4662,31 +5124,6 @@ static void check_ssl_policy(void) { CERT_CHAIN_POLICY_PARA policyPara = { 0 }; SSL_EXTRA_CERT_CHAIN_POLICY_PARA sslPolicyPara = { { 0 } }; - WCHAR winehq[] = { 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR google_dot_com[] = { 'w','w','w','.','g','o','o','g','l','e','.', - 'c','o','m',0 }; - WCHAR battle_dot_net[] = { 'w','w','w','.','b','a','t','t','l','e','.', - 'n','e','t',0 }; - WCHAR a_dot_openssl_dot_org[] = { 'a','.','o','p','e','n','s','s','l','.', - 'o','r','g',0 }; - WCHAR openssl_dot_org[] = { 'o','p','e','n','s','s','l','.','o','r','g',0 }; - WCHAR fopenssl_dot_org[] = { 'f','o','p','e','n','s','s','l','.', - 'o','r','g',0 }; - WCHAR a_dot_b_dot_openssl_dot_org[] = { 'a','.','b','.', - 'o','p','e','n','s','s','l','.','o','r','g',0 }; - WCHAR cs_dot_stanford_dot_edu[] = { 'c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR www_dot_cs_dot_stanford_dot_edu[] = { 'w','w','w','.','c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR a_dot_cs_dot_stanford_dot_edu[] = { 'a','.','c','s','.', - 's','t','a','n','f','o','r','d','.','e','d','u',0 }; - WCHAR test_dot_winehq_dot_org[] = { 't','e','s','t','.', - 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR a_dot_b_dot_winehq_dot_org[] = { 'a','.','b','.', - 'w','i','n','e','h','q','.','o','r','g',0 }; - WCHAR foo_dot_com[] = { 'f','o','o','.','c','o','m',0 }; - WCHAR afoo_dot_com[] = { 'a','f','o','o','.','c','o','m',0 }; - WCHAR a_dot_foo_dot_com[] = { 'a','.','f','o','o','.','c','o','m',0 }; HCERTSTORE testRoot; CERT_CHAIN_ENGINE_CONFIG engineConfig = { sizeof(engineConfig), 0 }; HCERTCHAINENGINE engine; @@ -4714,14 +5151,14 @@ static void check_ssl_policy(void) /* And again authenticating a client, but specify the size of the policy * parameter. */ - U(sslPolicyPara).cbSize = sizeof(sslPolicyCheck); + sslPolicyPara.cbSize = sizeof(sslPolicyCheck); sslPolicyPara.dwAuthType = AUTHTYPE_CLIENT; CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_SSL, NULL, sslPolicyCheck, &oct2007, &policyPara); /* One more time authenticating a client, but specify winehq.org as the * server name. */ - sslPolicyPara.pwszServerName = winehq; + sslPolicyPara.pwszServerName = (WCHAR *)L"winehq.org"; CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_SSL, NULL, sslPolicyCheck, &oct2007, &policyPara); /* And again authenticating a server, still specifying winehq.org as the @@ -4743,54 +5180,61 @@ static void check_ssl_policy(void) CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, ignoredUnknownCAPolicyCheck, &oct2007, &policyPara); sslPolicyPara.fdwChecks = 0; + /* And again, but specifying the ignore in dwFlags */ + policyPara.dwFlags = CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG; + CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, + ignoredUnknownCAPolicyCheck, &oct2007, &policyPara); /* And again, but checking the Google chain at a bad date */ - sslPolicyPara.pwszServerName = google_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.google.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, googlePolicyCheckWithMatchingNameExpired, &oct2007, &policyPara); + policyPara.dwFlags = 0; /* Again checking the Google chain at a bad date, but ignoring date * errors. */ - sslPolicyPara.fdwChecks = SECURITY_FLAG_IGNORE_CERT_DATE_INVALID; + sslPolicyPara.fdwChecks = SECURITY_FLAG_IGNORE_UNKNOWN_CA | + SECURITY_FLAG_IGNORE_CERT_DATE_INVALID; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, googlePolicyCheckWithMatchingName, &oct2007, &policyPara); - sslPolicyPara.fdwChecks = 0; /* And again, but checking the Google chain at a good date */ - sslPolicyPara.pwszServerName = google_dot_com; + sslPolicyPara.fdwChecks = SECURITY_FLAG_IGNORE_UNKNOWN_CA; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.google.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, googlePolicyCheckWithMatchingName, &nov2016, &policyPara); + sslPolicyPara.fdwChecks = 0; /* Check again with the openssl cert, which has a wildcard in its name, * with various combinations of matching and non-matching names. * With "a.openssl.org": match */ - sslPolicyPara.pwszServerName = a_dot_openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithMatchingName, &oct2009, &policyPara); /* With "openssl.org": no match */ - sslPolicyPara.pwszServerName = openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* With "fopenssl.org": no match */ - sslPolicyPara.pwszServerName = fopenssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"fopenssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* with "a.b.openssl.org": no match */ - sslPolicyPara.pwszServerName = a_dot_b_dot_openssl_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.b.openssl.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, opensslPolicyCheckWithoutMatchingName, &oct2009, &policyPara); /* Check again with the cs.stanford.edu, which has both cs.stanford.edu * and www.cs.stanford.edu in its subject alternative name. * With "cs.stanford.edu": match */ - sslPolicyPara.pwszServerName = cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithMatchingName, &nov2016, &policyPara); /* With "www.cs.stanford.edu": match */ - sslPolicyPara.pwszServerName = www_dot_cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithMatchingName, &nov2016, &policyPara); /* With "a.cs.stanford.edu": no match */ - sslPolicyPara.pwszServerName = a_dot_cs_dot_stanford_dot_edu; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.cs.stanford.edu"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, stanfordPolicyCheckWithoutMatchingName, &nov2016, &policyPara); /* Check chain29, which has a wildcard in its subject alternative name, @@ -4802,28 +5246,28 @@ static void check_ssl_policy(void) CertAddEncodedCertificateToStore(testRoot, X509_ASN_ENCODING, chain0_0, sizeof(chain0_0), CERT_STORE_ADD_ALWAYS, NULL); engineConfig.hExclusiveRoot = testRoot; - if (!pCertCreateCertificateChainEngine(&engineConfig, &engine)) + if (!CertCreateCertificateChainEngine(&engineConfig, &engine)) { skip("Couldn't create chain engine\n"); return; } /* With "winehq.org": no match */ - sslPolicyPara.pwszServerName = winehq; + sslPolicyPara.pwszServerName = (WCHAR *)L"winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* With "test.winehq.org": match */ - sslPolicyPara.pwszServerName = test_dot_winehq_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"test.winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithMatchingName, &oct2007, &policyPara); /* With "a.b.winehq.org": no match */ - sslPolicyPara.pwszServerName = a_dot_b_dot_winehq_dot_org; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.b.winehq.org"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* When specifying to ignore name mismatch: match */ sslPolicyPara.fdwChecks |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, engine, winehqPolicyCheckWithMatchingName, &oct2007, &policyPara); - pCertFreeCertificateChainEngine(engine); + CertFreeCertificateChainEngine(engine); CertCloseStore(testRoot, 0); /* Test chain30, which has an invalid critical extension in an intermediate * cert, against the SSL policy. @@ -4835,24 +5279,38 @@ static void check_ssl_policy(void) /* Test chain31, which has two CNs, "*.foo.com" and "foo.com", against * some names that match one of the CNs: */ - sslPolicyPara.pwszServerName = foo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"foo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithMatchingName, &oct2007, &policyPara); - sslPolicyPara.pwszServerName = a_dot_foo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"a.foo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithMatchingName, &oct2007, &policyPara); /* and against a name that doesn't match either CN: */ - sslPolicyPara.pwszServerName = afoo_dot_com; + sslPolicyPara.pwszServerName = (WCHAR *)L"afoo.com"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, fooPolicyCheckWithoutMatchingName, &oct2007, &policyPara); /* The Battle.Net chain checks a certificate with a domain component * containing a terminating NULL. */ - sslPolicyPara.pwszServerName = battle_dot_net; + sslPolicyPara.pwszServerName = (WCHAR *)L"www.battle.net"; CHECK_CHAIN_POLICY_STATUS(CERT_CHAIN_POLICY_SSL, NULL, nullTerminatedDomainComponentPolicyCheck, &oct2010, &policyPara); } +static void check_msroot_policy(void) +{ + CERT_CHAIN_POLICY_PARA para; + + CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_MICROSOFT_ROOT, NULL, + msRootPolicyCheck, &may2020, NULL); + + para.cbSize = sizeof(para); + para.pvExtraPolicyPara = NULL; + para.dwFlags = MICROSOFT_ROOT_CERT_CHAIN_POLICY_CHECK_APPLICATION_ROOT_FLAG; + CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_MICROSOFT_ROOT, NULL, + msRootPolicyCheck_approot, &may2020, ¶); +} + static void testVerifyCertChainPolicy(void) { BOOL ret; @@ -4862,58 +5320,52 @@ static void testVerifyCertChainPolicy(void) CERT_CHAIN_POLICY_STATUS policyStatus = { 0 }; CERT_CHAIN_POLICY_PARA policyPara = { 0 }; - if (!pCertVerifyCertificateChainPolicy) - { - win_skip("CertVerifyCertificateChainPolicy() is not available\n"); - return; - } - /* Crash - ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, &chainPara, NULL); */ SetLastError(0xdeadbeef); - ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); + ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Crashes - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, &policyStatus); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); - pCertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, + CertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, &chain); /* Crash - ret = pCertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = CertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, NULL); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &chainPara, NULL); */ /* Size of policy status is apparently ignored, as is pChainPolicyPara */ - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, &policyStatus); - ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT || policyStatus.dwError == TRUST_E_CERT_SIGNATURE, /* win7 + win8 */ - "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08x\n", policyStatus.dwError); + "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08lx\n", policyStatus.dwError); ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, - "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex, + "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &policyPara, &policyStatus); - ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT || policyStatus.dwError == TRUST_E_CERT_SIGNATURE, /* win7 + win8 */ - "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08x\n", policyStatus.dwError); + "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08lx\n", policyStatus.dwError); ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, - "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex, + "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - pCertFreeCertificateChain(chain); + CertFreeCertificateChain(chain); CertFreeCertificateContext(cert); check_base_policy(); @@ -4921,26 +5373,16 @@ static void testVerifyCertChainPolicy(void) check_authenticode_policy(); CHECK_CHAIN_POLICY_STATUS_ARRAY(CERT_CHAIN_POLICY_BASIC_CONSTRAINTS, NULL, basicConstraintsPolicyCheck, &oct2007, NULL); + check_msroot_policy(); } START_TEST(chain) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCertCreateCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertCreateCertificateChainEngine"); - pCertGetCertificateChain = (void*)GetProcAddress(hCrypt32, "CertGetCertificateChain"); - pCertFreeCertificateChain = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChain"); - pCertFreeCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChainEngine"); - pCertVerifyCertificateChainPolicy = (void*)GetProcAddress(hCrypt32, "CertVerifyCertificateChainPolicy"); - testCreateCertChainEngine(); - if (!pCertGetCertificateChain || !pCertFreeCertificateChain) - { - win_skip("Cert*CertificateChain functions not available\n"); - } - else - { - testVerifyCertChainPolicy(); - testGetCertChain(); - test_CERT_CHAIN_PARA_cbSize(); - } +#if defined(__REACTOS__) && defined(_M_IX86) + if ((GetVersion() & 0xFF) > 5) // testVerifyCertChainPolicy() hangs on Server 2003 x86 +#endif + testVerifyCertChainPolicy(); + testGetCertChain(); + test_CERT_CHAIN_PARA_cbSize(); } diff --git a/modules/rostests/winetests/crypt32/crl.c b/modules/rostests/winetests/crypt32/crl.c index c350b20f007..06cfc52fece 100644 --- a/modules/rostests/winetests/crypt32/crl.c +++ b/modules/rostests/winetests/crypt32/crl.c @@ -77,18 +77,6 @@ static const BYTE signedCRL[] = { 0x30, 0x45, 0x30, 0x2c, 0x30, 0x02, 0x06, 0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }; -static BOOL (WINAPI *pCertFindCertificateInCRL)(PCCERT_CONTEXT,PCCRL_CONTEXT,DWORD,void*,PCRL_ENTRY*); -static PCCRL_CONTEXT (WINAPI *pCertFindCRLInStore)(HCERTSTORE,DWORD,DWORD,DWORD,const void*,PCCRL_CONTEXT); -static BOOL (WINAPI *pCertIsValidCRLForCertificate)(PCCERT_CONTEXT, PCCRL_CONTEXT, DWORD, void*); - -static void init_function_pointers(void) -{ - HMODULE hdll = GetModuleHandleA("crypt32.dll"); - pCertFindCertificateInCRL = (void*)GetProcAddress(hdll, "CertFindCertificateInCRL"); - pCertFindCRLInStore = (void*)GetProcAddress(hdll, "CertFindCRLInStore"); - pCertIsValidCRLForCertificate = (void*)GetProcAddress(hdll, "CertIsValidCRLForCertificate"); -} - static void testCreateCRL(void) { PCCRL_CONTEXT context; @@ -96,11 +84,11 @@ static void testCreateCRL(void) context = CertCreateCRLContext(0, NULL, 0); ok(!context && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); context = CertCreateCRLContext(X509_ASN_ENCODING, NULL, 0); GLE = GetLastError(); - ok(!context && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE); + ok(!context && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE); context = CertCreateCRLContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ok(!context, "Expected failure\n"); context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL, @@ -108,11 +96,11 @@ static void testCreateCRL(void) ok(!context, "Expected failure\n"); context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL, sizeof(signedCRL)); - ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); if (context) CertFreeCRLContext(context); context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL)); - ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); if (context) CertFreeCRLContext(context); } @@ -148,86 +136,80 @@ static void testAddCRL(void) BOOL ret; DWORD GLE; - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (!store) return; /* Bad CRL encoding type */ ret = CertAddEncodedCRLToStore(0, 0, NULL, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, 0, NULL, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL), 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL), 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* No CRL */ ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, NULL, 0, 0, NULL); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE); + ok(!ret && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, NULL, 0, 0, NULL); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE); + ok(!ret && GLE == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE); - /* Weird--bad add disposition leads to an access violation in Windows. - * Both tests crash on some win9x boxes. - */ - if (0) - { - ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL, - sizeof(signedCRL), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG /* Vista */), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError()); - ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, - sizeof(signedCRL), 0, NULL); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == E_INVALIDARG /* Vista */), - "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError()); - } + ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL, + sizeof(signedCRL), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG /* Vista */), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError()); + ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, + sizeof(signedCRL), 0, NULL); + ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || + GetLastError() == E_INVALIDARG /* Vista */), + "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError()); /* Weird--can add a CRL to the NULL store (does this have special meaning?) */ context = NULL; ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); if (context) CertFreeCRLContext(context); /* Normal cases: a "signed" CRL is okay.. */ ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); /* and an unsigned one is too. */ ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, CRL, sizeof(CRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL, sizeof(newerCRL), CERT_STORE_ADD_NEW, NULL); ok(!ret && GetLastError() == CRYPT_E_EXISTS, - "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError()); + "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError()); /* This should replace (one of) the existing CRL(s). */ ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL, sizeof(newerCRL), CERT_STORE_ADD_NEWER, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); CertCloseStore(store, 0); @@ -433,43 +415,37 @@ static void testFindCRL(void) DWORD count, revoked_count; BOOL ret; - if (!pCertFindCRLInStore || !pCertFindCertificateInCRL) - { - win_skip("CertFindCRLInStore or CertFindCertificateInCRL not available\n"); - return; - } - store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (!store) return; ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); /* Crashes - context = pCertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); + context = CertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); */ /* Find any context */ - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* Bogus flags are ignored */ - context = pCertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* CRL encoding type is ignored too */ - context = pCertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); + context = CertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* This appears to match any cert */ - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); @@ -477,28 +453,28 @@ static void testFindCRL(void) /* Try to match an issuer that isn't in the store */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2, sizeof(bigCert2)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context == NULL, "Expected no matching context\n"); CertFreeCertificateContext(cert); /* Match an issuer that is in the store */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* Try various find flags */ - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, cert, NULL); - ok(!context || broken(context != NULL /* Win9x */), "unexpected context\n"); + ok(!context, "unexpected context\n"); /* The CRL doesn't have an AKI extension, so it matches any cert */ - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, cert, NULL); ok(context != NULL, "Expected a context\n"); if (context) @@ -507,22 +483,21 @@ static void testFindCRL(void) if (0) { /* Crash or return NULL/STATUS_ACCESS_VIOLATION */ - pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL, + CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL, NULL); - pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, NULL); } /* Test whether the cert matches the CRL in the store */ issuedForPara.pSubjectCert = cert; issuedForPara.pIssuerCert = cert; - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, NULL); - ok(context != NULL || broken(!context /* Win9x, NT4 */), - "Expected a context\n"); + ok(context != NULL, "Expected a context\n"); if (context) { ok(context->cbCrlEncoded == sizeof(signedCRL), - "unexpected CRL size %d\n", context->cbCrlEncoded); + "unexpected CRL size %ld\n", context->cbCrlEncoded); ok(!memcmp(context->pbCrlEncoded, signedCRL, context->cbCrlEncoded), "unexpected CRL data\n"); CertFreeCRLContext(context); @@ -531,27 +506,27 @@ static void testFindCRL(void) ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, v2CRLWithIssuingDistPoint, sizeof(v2CRLWithIssuingDistPoint), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); issuedForPara.pSubjectCert = cert; issuedForPara.pIssuerCert = cert; context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } @@ -560,40 +535,38 @@ static void testFindCRL(void) * match cert's issuer, but verisignCRL does not, so the expected count * is 0. */ - ok(count == 3 || broken(count == 0 /* NT4, Win9x */), - "expected 3 matching CRLs, got %d\n", count); + ok(count == 3, "expected 3 matching CRLs, got %ld\n", count); /* Only v1CRLWithIssuerAndEntry and v2CRLWithIssuingDistPoint contain * entries, so the count of CRL entries that match cert is 2. */ - ok(revoked_count == 2 || broken(revoked_count == 0 /* NT4, Win9x */), - "expected 2 matching CRL entries, got %d\n", revoked_count); + ok(revoked_count == 2, "expected 2 matching CRL entries, got %ld\n", revoked_count); CertFreeCertificateContext(cert); /* Try again with a cert that doesn't match any CRLs in the store */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); issuedForPara.pSubjectCert = cert; issuedForPara.pIssuerCert = cert; context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0, "expected 0 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); CertFreeCertificateContext(cert); @@ -602,28 +575,27 @@ static void testFindCRL(void) */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, verisignCommercialSoftPubCA, sizeof(verisignCommercialSoftPubCA)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); issuedForPara.pIssuerCert = cert; issuedForPara.pSubjectCert = cert; context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1 || broken(count == 0 /* Win9x, NT4 */), - "expected 1 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); CertFreeCertificateContext(cert); @@ -649,96 +621,93 @@ static void testFindCRL(void) context = NULL; count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, &issuedForPara, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1 || broken(count == 0 /* Win9x, NT4 */), - "expected 1 matching CRLs, got %d\n", count); - ok(revoked_count == 1 || broken(revoked_count == 0 /* Win9x, NT4 */), - "expected 1 matching CRL entries, got %d\n", revoked_count); + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); + ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n", revoked_count); /* Test CRL_FIND_ISSUED_BY flags */ count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, endCert, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0, "expected 0 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, + context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, rootCert, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1, "expected 1 matching CRLs, got %d\n", count); - ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n", + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); + ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, endCert, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0, "expected 0 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG, CRL_FIND_ISSUED_BY, rootCert, context); if (context) { PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0 || broken(count == 1 /* Win9x */), - "expected 0 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, endCert, context); if (context) @@ -746,17 +715,17 @@ static void testFindCRL(void) PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 0, "expected 0 matching CRLs, got %d\n", count); - ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n", + ok(count == 0, "expected 0 matching CRLs, got %ld\n", count); + ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n", revoked_count); count = revoked_count = 0; do { - context = pCertFindCRLInStore(store, 0, + context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, rootCert, context); if (context) @@ -764,13 +733,13 @@ static void testFindCRL(void) PCRL_ENTRY entry; count++; - if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && + if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) && entry) revoked_count++; } } while (context); - ok(count == 1, "expected 1 matching CRLs, got %d\n", count); - ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n", + ok(count == 1, "expected 1 matching CRLs, got %ld\n", count); + ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n", revoked_count); CertFreeCertificateContext(rootCert); CertFreeCertificateContext(endCert); @@ -787,7 +756,7 @@ static void testGetCRLFromStore(void) DWORD flags; BOOL ret; - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (!store) return; /* Crash @@ -799,17 +768,17 @@ static void testGetCRLFromStore(void) flags = 0xffffffff; context = CertGetCRLFromStore(store, NULL, NULL, &flags); ok(!context && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test an empty store */ flags = 0; context = CertGetCRLFromStore(store, NULL, NULL, &flags); ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); /* NULL matches any CRL */ flags = 0; @@ -820,17 +789,17 @@ static void testGetCRLFromStore(void) /* This cert's issuer isn't in */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2, sizeof(bigCert2)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); context = CertGetCRLFromStore(store, cert, NULL, &flags); ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); CertFreeCertificateContext(cert); /* But this one is */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); context = CertGetCRLFromStore(store, cert, NULL, &flags); ok(context != NULL, "Expected a context\n"); @@ -851,10 +820,10 @@ static void checkCRLHash(const BYTE *data, DWORD dataLen, ALG_ID algID, memset(hashProperty, 0, sizeof(hashProperty)); size = sizeof(hash); ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ret = CertGetCRLContextProperty(context, propID, hashProperty, &size); - ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError()); - ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n", + ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError()); + ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n", propID); } @@ -863,7 +832,7 @@ static void testCRLProperties(void) PCCRL_CONTEXT context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL)); - ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); if (context) { DWORD propID, numProps, access, size; @@ -882,12 +851,12 @@ static void testCRLProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 0, "Expected 0 properties, got %d\n", numProps); + ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps); /* Tests with a NULL cert context. Prop ID 0 fails.. */ ret = CertSetCRLContextProperty(NULL, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* while this just crashes. ret = CertSetCRLContextProperty(NULL, CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL); @@ -895,7 +864,7 @@ static void testCRLProperties(void) ret = CertSetCRLContextProperty(context, 0, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Can't set the cert property directly, this crashes. ret = CertSetCRLContextProperty(context, CERT_CRL_PROP_ID, 0, CRL); */ @@ -912,14 +881,14 @@ static void testCRLProperties(void) ret = CertGetCRLContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* And, an implicit property */ ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID, NULL, &size); - ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError()); ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID, &access, &size); - ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError()); ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG), "Didn't expect a persisted crl\n"); /* Trying to set this "read only" property crashes. @@ -932,16 +901,16 @@ static void testCRLProperties(void) blob.pbData = hash; blob.cbData = sizeof(hash); ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, &blob); - ok(ret, "CertSetCRLContextProperty failed: %08x\n", + ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError()); size = sizeof(hashProperty); ret = CertGetCRLContextProperty(context, CERT_HASH_PROP_ID, hashProperty, &size); - ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError()); ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n"); /* Delete the (bogus) hash, and get the real one */ ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, NULL); - ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError()); checkCRLHash(CRL, sizeof(CRL), CALG_SHA1, context, CERT_HASH_PROP_ID); /* Now that the hash property is set, we should get one property when @@ -954,7 +923,7 @@ static void testCRLProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 1, "Expected 1 properties, got %d\n", numProps); + ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps); /* Check a few other implicit properties */ checkCRLHash(CRL, sizeof(CRL), CALG_MD5, context, @@ -985,14 +954,12 @@ static void testIsValidCRLForCert(void) PCCRL_CONTEXT crl; HCERTSTORE store; - if(!pCertIsValidCRLForCertificate) return; - crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry)); - ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok(cert1 != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert1 != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); /* Crash @@ -1001,24 +968,24 @@ static void testIsValidCRLForCert(void) */ /* Curiously, any CRL is valid for the NULL certificate */ - ret = pCertIsValidCRLForCertificate(NULL, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(NULL, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); /* Same issuer for both cert and CRL, this CRL is valid for that cert */ - ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); cert2 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer)); - ok(cert2 != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert2 != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); /* Yet more curious: different issuers for these, yet the CRL is valid for * that cert. According to MSDN, the relevant bit to check is whether the * CRL has a CRL_ISSUING_DIST_POINT extension. */ - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); CertFreeCRLContext(crl); @@ -1027,38 +994,38 @@ static void testIsValidCRLForCert(void) */ crl = CertCreateCRLContext(X509_ASN_ENCODING, v2CRLWithIssuingDistPoint, sizeof(v2CRLWithIssuingDistPoint)); - ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); /* With a CRL_ISSUING_DIST_POINT in the CRL, it matches the cert containing * a CRL_DIST_POINTS_INFO extension. */ cert3 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCertWithCRLDistPoints, sizeof(bigCertWithCRLDistPoints)); - ok(cert3 != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert3 != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); CertFreeCRLContext(crl); /* And again, with a real CRL, the CRL is valid for all three certs. */ crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL)); - ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); CertFreeCRLContext(crl); @@ -1067,18 +1034,18 @@ static void testIsValidCRLForCert(void) */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, &crl); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); - ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL); - ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); + ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL); + ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError()); CertFreeCRLContext(crl); @@ -1103,46 +1070,40 @@ static void testFindCertInCRL(void) PCCRL_CONTEXT crl; PCRL_ENTRY entry; - if (!pCertFindCertificateInCRL) - { - win_skip("CertFindCertificateInCRL() is not available\n"); - return; - } - cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); /* Crash - ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, NULL); - ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); - ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); - ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); + ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); + ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); + ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, NULL); + ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); + ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); + ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); */ crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); - ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry == NULL, "Expected not to find an entry in CRL\n"); CertFreeCRLContext(crl); crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); - ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); /* Entry found even though CRL issuer doesn't match cert issuer */ crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer, sizeof(crlWithDifferentIssuer)); - ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); - ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); + ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); @@ -1156,18 +1117,18 @@ static void testVerifyCRLRevocation(void) PCCRL_CONTEXT crl; ret = CertVerifyCRLRevocation(0, NULL, 0, NULL); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, NULL, 0, NULL); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); /* Check against no CRL */ ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 0, NULL); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 0, NULL); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); /* Check against CRL with entry for the cert */ crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, @@ -1183,7 +1144,7 @@ static void testVerifyCRLRevocation(void) /* Check against CRL with different issuer and entry for the cert */ crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer, sizeof(crlWithDifferentIssuer)); - ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError()); + ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1, (PCRL_INFO *)&crl->pCrlInfo); ok(!ret, "CertVerifyCRLRevocation should have been revoked\n"); @@ -1194,10 +1155,10 @@ static void testVerifyCRLRevocation(void) sizeof(verisignCRL)); ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 1, (PCRL_INFO *)&crl->pCrlInfo); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1, (PCRL_INFO *)&crl->pCrlInfo); - ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError()); + ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError()); CertFreeCRLContext(crl); CertFreeCertificateContext(cert); @@ -1205,16 +1166,12 @@ static void testVerifyCRLRevocation(void) START_TEST(crl) { - init_function_pointers(); - testCreateCRL(); testDupCRL(); testAddCRL(); testFindCRL(); testGetCRLFromStore(); - testCRLProperties(); - testIsValidCRLForCert(); testFindCertInCRL(); testVerifyCRLRevocation(); diff --git a/modules/rostests/winetests/crypt32/ctl.c b/modules/rostests/winetests/crypt32/ctl.c index 79a60f8c6ee..05dc079ff64 100644 --- a/modules/rostests/winetests/crypt32/ctl.c +++ b/modules/rostests/winetests/crypt32/ctl.c @@ -114,57 +114,44 @@ static void testCreateCTL(void) SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(0, NULL, 0); ok(!ctl && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, NULL, 0); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == OSS_MORE_INPUT), /* win9x */ - "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* An empty CTL can't be created.. */ SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, emptyCTL, sizeof(emptyCTL)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* Nor can any of these "signed" CTLs whose inner content OID isn't * szOID_CTL. */ SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTL, sizeof(signedCTL)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), - "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", + GetLastError(), GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, ctlWithOneEntry, sizeof(ctlWithOneEntry)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == OSS_DATA_ERROR /* some win98 */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), - "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, OSS_DATA_ERROR, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); SetLastError(0xdeadbeef); ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithSubjectAlgorithm, sizeof(signedCTLWithSubjectAlgorithm)); - ok(!ctl && - (GetLastError() == ERROR_INVALID_DATA || - GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ || - GetLastError() == ERROR_SUCCESS /* some win98 */), - "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(), + ok(!ctl && GetLastError() == ERROR_INVALID_DATA, + "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(), GetLastError()); /* This signed CTL with the appropriate inner content type can be decoded. */ ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent)); - ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError()); + ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError()); if (ctl) { /* Even though the CTL was decoded with X509_ASN_ENCODING, the @@ -172,7 +159,7 @@ static void testCreateCTL(void) */ ok(ctl->dwMsgAndCertEncodingType == (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING), - "expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08x\n", + "expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08lx\n", ctl->dwMsgAndCertEncodingType); CertFreeCTLContext(ctl); } @@ -182,7 +169,7 @@ static void testCreateCTL(void) ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithCTLInnerContentAndBadSig, sizeof(signedCTLWithCTLInnerContentAndBadSig)); - ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError()); + ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError()); if (ctl) CertFreeCTLContext(ctl); } @@ -221,12 +208,12 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, memset(hashProperty, 0, sizeof(hashProperty)); size = sizeof(hash); ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ret = CertGetCTLContextProperty(context, propID, hashProperty, &size); - ok(ret, "CertGetCTLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); if (ret) ok(!memcmp(hash, hashProperty, size), - "Unexpected hash for property %d\n", propID); + "Unexpected hash for property %ld\n", propID); } static void testCTLProperties(void) @@ -237,11 +224,6 @@ static void testCTLProperties(void) ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent)); - if (!ctl) - { - skip("CertCreateCTLContext failed: %08x\n", GetLastError()); - return; - } /* No properties as yet */ propID = 0; @@ -251,17 +233,15 @@ static void testCTLProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 0, "Expected 0 properties, got %d\n", numProps); + ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps); /* An implicit property */ ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */), - "CertGetCTLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, &access, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */), - "CertGetCTLContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError()); if (ret) ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG), "Didn't expect a persisted cert\n"); @@ -279,7 +259,7 @@ static void testCTLProperties(void) if (propID) numProps++; } while (propID != 0); - ok(numProps == 1, "Expected 1 properties, got %d\n", numProps); + ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps); checkHash(signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CALG_MD5, ctl, @@ -360,12 +340,12 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithCTLInnerContentAndBadSig, sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); /* Check that two exist */ numCTLs = 0; ctl = NULL; @@ -374,7 +354,7 @@ static void testAddCTLToStore(void) if (ctl) numCTLs++; } while (ctl); - ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs); + ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs); CertCloseStore(store, 0); store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, @@ -383,15 +363,15 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); /* so adding the second CTL fails. */ SetLastError(0xdeadbeef); ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithCTLInnerContentAndBadSig, sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_NEW, NULL); - ok(!ret && (GetLastError() == CRYPT_E_EXISTS || GetLastError() == OSS_DATA_ERROR), - "expected CRYPT_E_EXISTS or OSS_DATA_ERROR, got %d %08x\n", ret, GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_EXISTS, + "expected CRYPT_E_EXISTS, got %d %08lx\n", ret, GetLastError()); CertCloseStore(store, 0); store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, @@ -402,13 +382,12 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); expectedCTLs = 1; ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithUsage, sizeof(signedCTLWithUsage), CERT_STORE_ADD_NEW, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* some win98 */), - "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); if (ret) expectedCTLs++; /* Check that two exist */ @@ -419,7 +398,7 @@ static void testAddCTLToStore(void) if (ctl) numCTLs++; } while (ctl); - ok(numCTLs == expectedCTLs, "expected %d CTLs, got %d\n", expectedCTLs, + ok(numCTLs == expectedCTLs, "expected %ld CTLs, got %ld\n", expectedCTLs, numCTLs); CertCloseStore(store, 0); @@ -431,16 +410,11 @@ static void testAddCTLToStore(void) ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithListID1, sizeof(signedCTLWithListID1), CERT_STORE_ADD_NEW, NULL); - if (!ret) - { - skip("adding a CTL with an empty usage not supported\n"); - return; - } - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING, signedCTLWithListID2, sizeof(signedCTLWithListID2), CERT_STORE_ADD_NEW, NULL); - ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError()); /* Check that two exist */ numCTLs = 0; ctl = NULL; @@ -449,7 +423,7 @@ static void testAddCTLToStore(void) if (ctl) numCTLs++; } while (ctl); - ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs); + ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs); CertCloseStore(store, 0); } diff --git a/modules/rostests/winetests/crypt32/encode.c b/modules/rostests/winetests/crypt32/encode.c index cea948151cd..1c27fff4787 100644 --- a/modules/rostests/winetests/crypt32/encode.c +++ b/modules/rostests/winetests/crypt32/encode.c @@ -27,9 +27,13 @@ #include "wine/test.h" - -static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*); -static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); +void CRYPT_CopyReversed(BYTE *dst, const BYTE *src, size_t len) +{ + DWORD i; + for (i = 0; i < len; i++) { + dst[len - i - 1] = src[i]; + } +} struct encodedInt { @@ -95,33 +99,29 @@ static void test_encodeInt(DWORD dwEncoding) BYTE *buf = NULL; /* CryptEncodeObjectEx with NULL bufSize crashes.. - ret = pCryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = CryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = pCryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = CryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - if (0) - { - /* check with NULL integer buffer. Windows XP incorrectly returns an - * NTSTATUS (crashes on win9x). - */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, - &bufSize); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); + + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, + &bufSize); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + for (i = 0; i < ARRAY_SIZE(ints); i++) { /* encode as normal integer */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, NULL, NULL, &bufSize); - ok(ret, "Expected success, got %d\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", @@ -135,12 +135,12 @@ static void test_encodeInt(DWORD dwEncoding) /* encode as multibyte integer */ blob.cbData = sizeof(ints[i].val); blob.pbData = (BYTE *)&ints[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); - ok(ret, "Expected success, got %d\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", @@ -159,12 +159,12 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigInts[i].val); blob.pbData = (BYTE *)bigInts[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); - ok(ret, "Expected success, got %d\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", @@ -182,12 +182,12 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigUInts[i].val); blob.pbData = (BYTE*)bigUInts[i].val; - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, 0, NULL, NULL, &bufSize); - ok(ret, "Expected success, got %d\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", @@ -215,47 +215,43 @@ static void test_decodeInt(DWORD dwEncoding) BOOL ret; /* CryptDecodeObjectEx with NULL bufSize crashes.. - ret = pCryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, + ret = CryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = pCryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, + ret = CryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* check with NULL integer buffer */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* check with a valid, but too large, integer */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok((!ret && GetLastError() == CRYPT_E_ASN1_LARGE) || - broken(ret) /* Win9x */, - "Expected CRYPT_E_ASN1_LARGE, got %d\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, + "Expected CRYPT_E_ASN1_LARGE, got %ld\n", GetLastError()); /* check with a DER-encoded string */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); for (i = 0; i < ARRAY_SIZE(ints); i++) { /* When the output buffer is NULL, this always succeeds */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, - "Expected success and NOERROR, got %d\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); - ok(bufSize == sizeof(int), "Wrong size %d\n", bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize == sizeof(int), "Wrong size %ld\n", bufSize); ok(buf != NULL, "Expected allocated buffer\n"); if (ret) { @@ -266,23 +262,23 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(bigInts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, - "Expected success and NOERROR, got %d\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); - ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize); ok(buf != NULL, "Expected allocated buffer\n"); if (ret) { CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; ok(blob->cbData == strlen((const char*)bigInts[i].decoded), - "Expected len %d, got %d\n", lstrlenA((const char*)bigInts[i].decoded), + "Expected len %d, got %ld\n", lstrlenA((const char*)bigInts[i].decoded), blob->cbData); ok(!memcmp(blob->pbData, bigInts[i].decoded, blob->cbData), "Unexpected value\n"); @@ -291,23 +287,23 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(bigUInts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, - "Expected success and NOERROR, got %d\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); - ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize); ok(buf != NULL, "Expected allocated buffer\n"); if (ret) { CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; ok(blob->cbData == strlen((const char*)bigUInts[i].val), - "Expected len %d, got %d\n", lstrlenA((const char*)bigUInts[i].val), + "Expected len %d, got %ld\n", lstrlenA((const char*)bigUInts[i].val), blob->cbData); ok(!memcmp(blob->pbData, bigUInts[i].val, blob->cbData), "Unexpected value\n"); @@ -315,18 +311,18 @@ static void test_decodeInt(DWORD dwEncoding) } } /* Decode the value 1 with long-form length */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf); LocalFree(buf); } /* check with extra bytes at the end */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf); @@ -338,7 +334,7 @@ static void test_decodeInt(DWORD dwEncoding) * Under XP it fails with CRYPT_E_ASN1_LARGE, which means there's a limit * on the size decoded, but in ME it fails with CRYPT_E_ASN1_EOD or crashes. * So this test unfortunately isn't useful. - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, 0x7fffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, "Expected CRYPT_E_ASN1_LARGE, got %08x\n", GetLastError()); @@ -349,10 +345,10 @@ static void test_decodeInt(DWORD dwEncoding) if (0) { /* a large buffer isn't guaranteed to crash, it depends on memory allocation order */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, 0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); } } @@ -385,10 +381,10 @@ static void test_encodeEnumerated(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = CryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], &enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { ok(buf[0] == 0xa, @@ -418,12 +414,12 @@ static void test_decodeEnumerated(DWORD dwEncoding) DWORD bufSize = sizeof(int); int val; - ret = pCryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = CryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL, &val, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); ok(bufSize == sizeof(int), - "Got unexpected size %d for enumerated\n", bufSize); + "Got unexpected size %ld for enumerated\n", bufSize); ok(val == enums[j].val, "Unexpected value %d, expected %d\n", val, enums[j].val); } @@ -445,8 +441,8 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, BOOL ret; ret = SystemTimeToFileTime(&time->sysTime, &ft); - ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, structType, &ft, + ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, structType, &ft, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -454,7 +450,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, if (structType == X509_CHOICE_OF_TIME || (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) { - ok(ret, "CryptEncodeObjectEx failed: %d (0x%08x)\n", GetLastError(), + ok(ret, "CryptEncodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), GetLastError()); ok(buf != NULL, "Expected an allocated buffer\n"); if (ret) @@ -462,7 +458,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, ok(buf[0] == time->encodedTime[0], "Expected type 0x%02x, got 0x%02x\n", time->encodedTime[0], buf[0]); - ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %d\n", + ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %ld\n", time->encodedTime[1], bufSize); ok(!memcmp(time->encodedTime + 2, buf + 2, time->encodedTime[1]), "Got unexpected value for time encoding\n"); @@ -470,9 +466,8 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, } } else - ok((!ret && GetLastError() == CRYPT_E_BAD_ENCODE) || - broken(GetLastError() == ERROR_SUCCESS), - "Expected CRYPT_E_BAD_ENCODE, got 0x%08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_BAD_ENCODE, + "Expected CRYPT_E_BAD_ENCODE, got 0x%08lx\n", GetLastError()); } static const char *printSystemTime(const SYSTEMTIME *st) @@ -500,20 +495,13 @@ static void compareTime(const SYSTEMTIME *expected, const FILETIME *got) SYSTEMTIME st; FileTimeToSystemTime(got, &st); - ok((expected->wYear == st.wYear && + ok(expected->wYear == st.wYear && expected->wMonth == st.wMonth && expected->wDay == st.wDay && expected->wHour == st.wHour && expected->wMinute == st.wMinute && expected->wSecond == st.wSecond && - abs(expected->wMilliseconds - st.wMilliseconds) <= 1) || - /* Some Windows systems only seem to be accurate in their time decoding to - * within about an hour. - */ - broken(expected->wYear == st.wYear && - expected->wMonth == st.wMonth && - expected->wDay == st.wDay && - abs(expected->wHour - st.wHour) <= 1), + abs(expected->wMilliseconds - st.wMilliseconds) <= 1, "Got unexpected value for time decoding:\nexpected %s, got %s\n", printSystemTime(expected), printFileTime(got)); } @@ -525,7 +513,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, DWORD size = sizeof(ft); BOOL ret; - ret = pCryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, + ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, time->encodedTime[1] + 2, 0, NULL, &ft, &size); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -533,17 +521,14 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, if (structType == X509_CHOICE_OF_TIME || (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) { - ok(ret || broken(GetLastError() == OSS_DATA_ERROR), - "CryptDecodeObjectEx failed: %d (0x%08x)\n", GetLastError(), + ok(ret, "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), GetLastError()); if (ret) compareTime(&time->sysTime, &ft); } else - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); } static const BYTE bin20[] = { @@ -638,12 +623,12 @@ static void test_decodeFiletime(DWORD dwEncoding) /* Check bogus length with non-NULL buffer */ ret = SystemTimeToFileTime(×[0].sysTime, &ft1); - ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError()); + ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); size = 1; - ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size); ok(!ret && GetLastError() == ERROR_MORE_DATA, - "Expected ERROR_MORE_DATA, got %d\n", GetLastError()); + "Expected ERROR_MORE_DATA, got %ld\n", GetLastError()); /* Normal tests */ for (i = 0; i < ARRAY_SIZE(times); i++) { @@ -660,13 +645,10 @@ static void test_decodeFiletime(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(bogusTimes); i++) { size = sizeof(ft1); - ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, bogusTimes[i], bogusTimes[i][1] + 2, 0, NULL, &ft1, &size); - ok((!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */)) || - broken(ret), /* Win9x and NT4 for bin38 */ - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); } } @@ -752,70 +734,55 @@ static void test_encodeName(DWORD dwEncoding) DWORD size = 0; BOOL ret; - if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!memcmp(buf, emptySequence, sizeof(emptySequence)), "Got unexpected encoding for empty name\n"); LocalFree(buf); } - if (0) - { - /* Test with bogus CERT_RDN (crashes on win9x) */ - info.cRDN = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + + /* Test with bogus CERT_RDN */ + info.cRDN = 1; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_RDN */ rdn.cRDNAttr = 0; rdn.rgRDNAttr = NULL; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!memcmp(buf, emptyRDNs, sizeof(emptyRDNs)), "Got unexpected encoding for empty RDN array\n"); LocalFree(buf); } - if (0) - { - /* Test with bogus attr array (crashes on win9x) */ - rdn.cRDNAttr = 1; - rdn.rgRDNAttr = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } - /* oddly, a bogus OID is accepted by Windows XP; not testing. - attrs[0].pszObjId = "bogus"; - attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; - attrs[0].Value.cbData = sizeof(commonName); - attrs[0].Value.pbData = commonName; + + /* Test with bogus attr array */ rdn.cRDNAttr = 1; - rdn.rgRDNAttr = attrs; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + rdn.rgRDNAttr = NULL; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret, "Expected failure, got success\n"); - */ + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Check with two CERT_RDN_ATTRs. Note DER encoding forces the order of * the encoded attributes to be swapped. */ @@ -829,9 +796,9 @@ static void test_encodeName(DWORD dwEncoding) attrs[1].Value.pbData = (BYTE *)surName; rdn.cRDNAttr = 2; rdn.rgRDNAttr = attrs; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!memcmp(buf, twoRDNs, sizeof(twoRDNs)), @@ -843,12 +810,12 @@ static void test_encodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size); + ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size); ok(!memcmp(buf, encodedTwoRDNs, size), "Unexpected value for re-encoded two RDN array\n"); LocalFree(buf); @@ -856,10 +823,10 @@ static void test_encodeName(DWORD dwEncoding) /* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test a more complex name */ rdn.cRDNAttr = ARRAY_SIZE(rdnAttrs); rdn.rgRDNAttr = rdnAttrs; @@ -867,20 +834,17 @@ static void test_encodeName(DWORD dwEncoding) info.rgRDN = &rdn; buf = NULL; size = 0; - ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(encodedRDNAttrs), "Wrong size %d\n", size); + ok(size == sizeof(encodedRDNAttrs), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedRDNAttrs, size), "Unexpected value\n"); LocalFree(buf); } } -static WCHAR commonNameW[] = { 'J','u','a','n',' ','L','a','n','g',0 }; -static WCHAR surNameW[] = { 'L','a','n','g',0 }; - static const BYTE twoRDNsNoNull[] = { 0x30,0x21,0x31,0x1f,0x30,0x0b,0x06,0x03,0x55,0x04,0x04,0x13,0x04,0x4c,0x61, 0x6e,0x67,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e, @@ -902,20 +866,17 @@ static void test_encodeUnicodeName(DWORD dwEncoding) DWORD size = 0; BOOL ret; - if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!memcmp(buf, emptySequence, sizeof(emptySequence)), @@ -927,35 +888,35 @@ static void test_encodeUnicodeName(DWORD dwEncoding) */ attrs[0].pszObjId = oid_common_name; attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; - attrs[0].Value.cbData = sizeof(commonNameW); - attrs[0].Value.pbData = (BYTE *)commonNameW; + attrs[0].Value.cbData = sizeof(L"Juan Lang"); + attrs[0].Value.pbData = (BYTE *)L"Juan Lang"; rdn.cRDNAttr = 1; rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_PRINTABLE_STRING, - "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08x\n", GetLastError()); - ok(size == 9, "Unexpected error index %08x\n", size); + "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08lx\n", GetLastError()); + ok(size == 9, "Unexpected error index %08lx\n", size); /* Check with two NULL-terminated CERT_RDN_ATTRs. Note DER encoding * forces the order of the encoded attributes to be swapped. */ attrs[0].pszObjId = oid_common_name; attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; attrs[0].Value.cbData = 0; - attrs[0].Value.pbData = (BYTE *)commonNameW; + attrs[0].Value.pbData = (BYTE *)L"Juan Lang"; attrs[1].pszObjId = oid_sur_name; attrs[1].dwValueType = CERT_RDN_PRINTABLE_STRING; attrs[1].Value.cbData = 0; - attrs[1].Value.pbData = (BYTE *)surNameW; + attrs[1].Value.pbData = (BYTE *)L"Lang"; rdn.cRDNAttr = 2; rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!memcmp(buf, twoRDNsNoNull, sizeof(twoRDNsNoNull)), @@ -967,12 +928,12 @@ static void test_encodeUnicodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size); + ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size); ok(!memcmp(buf, encodedTwoRDNs, size), "Unexpected value for re-encoded two RDN array\n"); LocalFree(buf); @@ -980,12 +941,12 @@ static void test_encodeUnicodeName(DWORD dwEncoding) /* Unicode names infer the type for CERT_RDN_ANY_TYPE */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - todo_wine ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + todo_wine ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(anyType), "Unexpected size %d\n", size); + ok(size == sizeof(anyType), "Unexpected size %ld\n", size); ok(!memcmp(buf, anyType, size), "Unexpected value\n"); LocalFree(buf); } @@ -994,24 +955,17 @@ static void test_encodeUnicodeName(DWORD dwEncoding) static void compareNameValues(const CERT_NAME_VALUE *expected, const CERT_NAME_VALUE *got) { - if (expected->dwValueType == CERT_RDN_UTF8_STRING && - got->dwValueType == CERT_RDN_ENCODED_BLOB) - { - win_skip("Can't handle CERT_RDN_UTF8_STRING\n"); - return; - } - ok(got->dwValueType == expected->dwValueType, - "Expected string type %d, got %d\n", expected->dwValueType, + "Expected string type %ld, got %ld\n", expected->dwValueType, got->dwValueType); ok(got->Value.cbData == expected->Value.cbData || got->Value.cbData == expected->Value.cbData - sizeof(WCHAR) /* Win8 */, - "String type %d: unexpected data size, got %d, expected %d\n", + "String type %ld: unexpected data size, got %ld, expected %ld\n", expected->dwValueType, got->Value.cbData, expected->Value.cbData); if (got->Value.cbData && got->Value.pbData) ok(!memcmp(got->Value.pbData, expected->Value.pbData, min(got->Value.cbData, expected->Value.cbData)), - "String type %d: unexpected value\n", expected->dwValueType); + "String type %ld: unexpected value\n", expected->dwValueType); } static void compareRDNAttrs(const CERT_RDN_ATTR *expected, @@ -1035,7 +989,7 @@ static void compareRDNAttrs(const CERT_RDN_ATTR *expected, static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got) { ok(got->cRDNAttr == expected->cRDNAttr, - "Expected %d RDN attrs, got %d\n", expected->cRDNAttr, got->cRDNAttr); + "Expected %ld RDN attrs, got %ld\n", expected->cRDNAttr, got->cRDNAttr); if (got->cRDNAttr) { DWORD i; @@ -1048,7 +1002,7 @@ static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got) static void compareNames(const CERT_NAME_INFO *expected, const CERT_NAME_INFO *got) { - ok(got->cRDN == expected->cRDN, "Expected %d RDNs, got %d\n", + ok(got->cRDN == expected->cRDN, "Expected %ld RDNs, got %ld\n", expected->cRDN, got->cRDN); if (got->cRDN) { @@ -1075,42 +1029,42 @@ static void test_decodeName(DWORD dwEncoding) /* test empty name */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); /* Interestingly, in Windows, if cRDN is 0, rgRGN may not be NULL. My * decoder works the same way, so only test the count. */ if (ret) { - ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %d\n", bufSize); + ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize); ok(((CERT_NAME_INFO *)buf)->cRDN == 0, - "Expected 0 RDNs in empty info, got %d\n", + "Expected 0 RDNs in empty info, got %ld\n", ((CERT_NAME_INFO *)buf)->cRDN); LocalFree(buf); } /* test empty name with indefinite-length encoding */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, sizeof(emptyIndefiniteSequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %d\n", bufSize); + ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize); ok(((CERT_NAME_INFO *)buf)->cRDN == 0, - "Expected 0 RDNs in empty info, got %d\n", + "Expected 0 RDNs in empty info, got %ld\n", ((CERT_NAME_INFO *)buf)->cRDN); LocalFree(buf); } /* test empty RDN */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf; @@ -1122,11 +1076,11 @@ static void test_decodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, twoRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { static CHAR oid_sur_name[] = szOID_SUR_NAME, @@ -1146,15 +1100,15 @@ static void test_decodeName(DWORD dwEncoding) } /* test that two RDN attrs with extra bytes succeeds */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, sizeof(twoRDNsExtraBytes), 0, NULL, NULL, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); /* And, a slightly more complicated name */ buf = NULL; bufSize = 0; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, sizeof(encodedRDNAttrs), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { rdn.cRDNAttr = ARRAY_SIZE(decodedRdnAttrs); @@ -1174,27 +1128,27 @@ static void test_decodeUnicodeName(DWORD dwEncoding) /* test empty name */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == sizeof(CERT_NAME_INFO), - "Got wrong bufSize %d\n", bufSize); + "Got wrong bufSize %ld\n", bufSize); ok(((CERT_NAME_INFO *)buf)->cRDN == 0, - "Expected 0 RDNs in empty info, got %d\n", + "Expected 0 RDNs in empty info, got %ld\n", ((CERT_NAME_INFO *)buf)->cRDN); LocalFree(buf); } /* test empty RDN */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf; @@ -1206,11 +1160,11 @@ static void test_decodeUnicodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, sizeof(twoRDNsNoNull), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { static CHAR oid_sur_name[] = szOID_SUR_NAME, @@ -1218,9 +1172,9 @@ static void test_decodeUnicodeName(DWORD dwEncoding) CERT_RDN_ATTR attrs[] = { { oid_sur_name, CERT_RDN_PRINTABLE_STRING, - { lstrlenW(surNameW) * sizeof(WCHAR), (BYTE *)surNameW } }, + { lstrlenW(L"Lang") * sizeof(WCHAR), (BYTE *)L"Lang" } }, { oid_common_name, CERT_RDN_PRINTABLE_STRING, - { lstrlenW(commonNameW) * sizeof(WCHAR), (BYTE *)commonNameW } }, + { lstrlenW(L"Juan Lang") * sizeof(WCHAR), (BYTE *)L"Juan Lang" } }, }; rdn.cRDNAttr = ARRAY_SIZE(attrs); @@ -1289,9 +1243,9 @@ static struct EncodedNameValue nameValues[] = { visibleCommonNameValue, sizeof(visibleCommonNameValue) }, { { CERT_RDN_GENERAL_STRING, { sizeof(commonName), (BYTE *)commonName } }, generalCommonNameValue, sizeof(generalCommonNameValue) }, - { { CERT_RDN_BMP_STRING, { sizeof(commonNameW), (BYTE *)commonNameW } }, + { { CERT_RDN_BMP_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } }, bmpCommonNameValue, sizeof(bmpCommonNameValue) }, - { { CERT_RDN_UTF8_STRING, { sizeof(commonNameW), (BYTE *)commonNameW } }, + { { CERT_RDN_UTF8_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } }, utf8CommonNameValue, sizeof(utf8CommonNameValue) }, /* The following tests succeed under Windows, but really should fail, * they contain characters that are illegal for the encoding. I'm @@ -1321,12 +1275,12 @@ static void test_encodeNameValue(DWORD dwEncoding) value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = printableCommonNameValue; value.Value.cbData = sizeof(printableCommonNameValue); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(printableCommonNameValue), "Unexpected size %d\n", + ok(size == sizeof(printableCommonNameValue), "Unexpected size %ld\n", size); ok(!memcmp(buf, printableCommonNameValue, size), "Unexpected encoding\n"); @@ -1334,29 +1288,27 @@ static void test_encodeNameValue(DWORD dwEncoding) } for (i = 0; i < ARRAY_SIZE(nameValues); i++) { - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */, - "Type %d: CryptEncodeObjectEx failed: %08x\n", + ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n", nameValues[i].value.dwValueType, GetLastError()); if (ret) { ok(size == nameValues[i].encodedSize, - "Expected size %d, got %d\n", nameValues[i].encodedSize, size); + "Expected size %ld, got %ld\n", nameValues[i].encodedSize, size); ok(!memcmp(buf, nameValues[i].encoded, size), "Got unexpected encoding\n"); LocalFree(buf); } } - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &embeddedNullNameValue.value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */, - "Type %d: CryptEncodeObjectEx failed: %08x\n", + ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n", embeddedNullNameValue.value.dwValueType, GetLastError()); if (ret) { ok(size == embeddedNullNameValue.encodedSize, - "Expected size %d, got %d\n", embeddedNullNameValue.encodedSize, size); + "Expected size %ld, got %ld\n", embeddedNullNameValue.encodedSize, size); ok(!memcmp(buf, embeddedNullNameValue.encoded, size), "Got unexpected encoding\n"); LocalFree(buf); @@ -1372,11 +1324,11 @@ static void test_decodeNameValue(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(nameValues); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, nameValues[i].encoded, nameValues[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); - ok(ret, "Value type %d: CryptDecodeObjectEx failed: %08x\n", + ok(ret, "Value type %ld: CryptDecodeObjectEx failed: %08lx\n", nameValues[i].value.dwValueType, GetLastError()); if (ret) { @@ -1385,7 +1337,7 @@ static void test_decodeNameValue(DWORD dwEncoding) LocalFree(buf); } } - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, embeddedNullNameValue.encoded, embeddedNullNameValue.encodedSize, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, &buf, &bufSize); @@ -1407,7 +1359,7 @@ static void test_decodeNameValue(DWORD dwEncoding) */ ok(got->dwValueType == CERT_RDN_ENCODED_BLOB || got->dwValueType == CERT_RDN_IA5_STRING, - "Expected CERT_RDN_ENCODED_BLOB or CERT_RDN_IA5_STRING, got %d\n", + "Expected CERT_RDN_ENCODED_BLOB or CERT_RDN_IA5_STRING, got %ld\n", got->dwValueType); if (got->dwValueType == CERT_RDN_ENCODED_BLOB) expected = &rdnEncodedValue; @@ -1416,12 +1368,12 @@ static void test_decodeNameValue(DWORD dwEncoding) if (expected) { ok(got->Value.cbData == expected->Value.cbData, - "String type %d: unexpected data size, got %d, expected %d\n", + "String type %ld: unexpected data size, got %ld, expected %ld\n", got->dwValueType, got->Value.cbData, expected->Value.cbData); if (got->Value.cbData && got->Value.pbData) ok(!memcmp(got->Value.pbData, expected->Value.pbData, min(got->Value.cbData, expected->Value.cbData)), - "String type %d: unexpected value\n", expected->dwValueType); + "String type %ld: unexpected value\n", expected->dwValueType); } LocalFree(buf); } @@ -1429,14 +1381,11 @@ static void test_decodeNameValue(DWORD dwEncoding) static const BYTE emptyURL[] = { 0x30, 0x02, 0x86, 0x00 }; static const BYTE emptyURLExtraBytes[] = { 0x30, 0x02, 0x86, 0x00, 0, 0, 0 }; -static const WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e', - 'h','q','.','o','r','g',0 }; +static const WCHAR url[] = L"http://winehq.org"; static const BYTE encodedURL[] = { 0x30, 0x13, 0x86, 0x11, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 }; -static const WCHAR nihongoURL[] = { 'h','t','t','p',':','/','/',0x226f, - 0x575b, 0 }; -static const WCHAR dnsName[] = { 'w','i','n','e','h','q','.','o','r','g',0 }; +static const WCHAR dnsName[] = L"winehq.org"; static const BYTE encodedDnsName[] = { 0x30, 0x0c, 0x82, 0x0a, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 }; static const BYTE localhost[] = { 127, 0, 0, 1 }; @@ -1459,56 +1408,56 @@ static void test_encodeAltName(DWORD dwEncoding) char oid[] = "1.2.3"; /* Test with empty info */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(emptySequence), "Wrong size %d\n", size); + ok(size == sizeof(emptySequence), "Wrong size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "Unexpected value\n"); LocalFree(buf); } /* Test with an empty entry */ info.cAltEntry = 1; info.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with an empty pointer */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(emptyURL), "Wrong size %d\n", size); + ok(size == sizeof(emptyURL), "Wrong size %ld\n", size); ok(!memcmp(buf, emptyURL, size), "Unexpected value\n"); LocalFree(buf); } /* Test with a real URL */ - U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.pwszURL = (LPWSTR)url; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(encodedURL), "Wrong size %d\n", size); + ok(size == sizeof(encodedURL), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedURL, size), "Unexpected value\n"); LocalFree(buf); } /* Now with the URL containing an invalid IA5 char */ - U(entry).pwszURL = (LPWSTR)nihongoURL; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.pwszURL = (WCHAR *)L"http://\x226f\x575b"; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, - "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError()); /* The first invalid character is at index 7 */ ok(GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size) == 7, - "Expected invalid char at index 7, got %d\n", + "Expected invalid char at index 7, got %ld\n", GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* Now with the URL missing a scheme */ - U(entry).pwszURL = (LPWSTR)dnsName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.pwszURL = (LPWSTR)dnsName; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { /* This succeeds, but it shouldn't, so don't worry about conforming */ @@ -1516,47 +1465,47 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Now with a DNS name */ entry.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(encodedDnsName), "Wrong size %d\n", size); + ok(size == sizeof(encodedDnsName), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedDnsName, size), "Unexpected value\n"); LocalFree(buf); } /* Test with an IP address */ entry.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; - U(entry).IPAddress.cbData = sizeof(localhost); - U(entry).IPAddress.pbData = (LPBYTE)localhost; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.IPAddress.cbData = sizeof(localhost); + entry.IPAddress.pbData = (LPBYTE)localhost; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(encodedIPAddr), "Wrong size %d\n", size); + ok(size == sizeof(encodedIPAddr), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedIPAddr, size), "Unexpected value\n"); LocalFree(buf); } /* Test with OID */ entry.dwAltNameChoice = CERT_ALT_NAME_REGISTERED_ID; - U(entry).pszRegisteredID = oid; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.pszRegisteredID = oid; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(encodedOidName), "Wrong size %d\n", size); + ok(size == sizeof(encodedOidName), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedOidName, size), "Unexpected value\n"); LocalFree(buf); } /* Test with directory name */ entry.dwAltNameChoice = CERT_ALT_NAME_DIRECTORY_NAME; - U(entry).DirectoryName.cbData = sizeof(encodedCommonName); - U(entry).DirectoryName.pbData = (LPBYTE)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + entry.DirectoryName.cbData = sizeof(encodedCommonName); + entry.DirectoryName.pbData = (LPBYTE)encodedCommonName; + ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(encodedDirectoryName), "Wrong size %d\n", size); + ok(size == sizeof(encodedDirectoryName), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedDirectoryName, size), "Unexpected value\n"); LocalFree(buf); } @@ -1580,172 +1529,164 @@ static void test_decodeAltName(DWORD dwEncoding) CERT_ALT_NAME_INFO *info; /* Test some bogus ones first */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, unimplementedType, sizeof(unimplementedType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n", - GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, bogusType, sizeof(bogusType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Now expected cases */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 0, "Expected 0 entries, got %d\n", + ok(info->cAltEntry == 0, "Expected 0 entries, got %ld\n", info->cAltEntry); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, emptyURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL, - "Expected CERT_ALT_NAME_URL, got %d\n", + "Expected CERT_ALT_NAME_URL, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(U(info->rgAltEntry[0]).pwszURL == NULL || !*U(info->rgAltEntry[0]).pwszURL, + ok(info->rgAltEntry[0].pwszURL == NULL || !*info->rgAltEntry[0].pwszURL, "Expected empty URL\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURLExtraBytes, sizeof(emptyURLExtraBytes), 0, NULL, NULL, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, encodedURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL, - "Expected CERT_ALT_NAME_URL, got %d\n", + "Expected CERT_ALT_NAME_URL, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszURL, url), "Unexpected URL\n"); + ok(!lstrcmpW(info->rgAltEntry[0].pwszURL, url), "Unexpected URL\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, encodedDnsName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME, - "Expected CERT_ALT_NAME_DNS_NAME, got %d\n", + "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszDNSName, dnsName), + ok(!lstrcmpW(info->rgAltEntry[0].pwszDNSName, dnsName), "Unexpected DNS name\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, encodedIPAddr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_IP_ADDRESS, - "Expected CERT_ALT_NAME_IP_ADDRESS, got %d\n", + "Expected CERT_ALT_NAME_IP_ADDRESS, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(U(info->rgAltEntry[0]).IPAddress.cbData == sizeof(localhost), - "Unexpected IP address length %d\n", - U(info->rgAltEntry[0]).IPAddress.cbData); - ok(!memcmp(U(info->rgAltEntry[0]).IPAddress.pbData, localhost, + ok(info->rgAltEntry[0].IPAddress.cbData == sizeof(localhost), + "Unexpected IP address length %ld\n", + info->rgAltEntry[0].IPAddress.cbData); + ok(!memcmp(info->rgAltEntry[0].IPAddress.pbData, localhost, sizeof(localhost)), "Unexpected IP address value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_REGISTERED_ID, - "Expected CERT_ALT_NAME_REGISTERED_ID, got %d\n", + "Expected CERT_ALT_NAME_REGISTERED_ID, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(!strcmp(U(info->rgAltEntry[0]).pszRegisteredID, "1.2.3"), - "Expected OID 1.2.3, got %s\n", U(info->rgAltEntry[0]).pszRegisteredID); + ok(!strcmp(info->rgAltEntry[0].pszRegisteredID, "1.2.3"), + "Expected OID 1.2.3, got %s\n", info->rgAltEntry[0].pszRegisteredID); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDirectoryName, sizeof(encodedDirectoryName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DIRECTORY_NAME, - "Expected CERT_ALT_NAME_DIRECTORY_NAME, got %d\n", + "Expected CERT_ALT_NAME_DIRECTORY_NAME, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); - ok(U(info->rgAltEntry[0]).DirectoryName.cbData == - sizeof(encodedCommonName), "Unexpected directory name length %d\n", - U(info->rgAltEntry[0]).DirectoryName.cbData); - ok(!memcmp(U(info->rgAltEntry[0]).DirectoryName.pbData, + ok(info->rgAltEntry[0].DirectoryName.cbData == + sizeof(encodedCommonName), "Unexpected directory name length %ld\n", + info->rgAltEntry[0].DirectoryName.cbData); + ok(!memcmp(info->rgAltEntry[0].DirectoryName.pbData, encodedCommonName, sizeof(encodedCommonName)), "Unexpected directory name value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, dns_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - /* Fails on WinXP with CRYPT_E_ASN1_RULE. I'm not too concerned about the - * particular failure, just that it doesn't decode. - * It succeeds on (broken) Windows versions that haven't addressed - * embedded NULLs in alternate names. - */ - ok(!ret || broken(ret), "expected failure\n"); +#if defined(__REACTOS__) && defined(_M_AMD64) + if ((GetVersion() & 0xFFFF) != 0x0006) // Next test fails on Vista x64 +#endif + ok(!ret, "expected failure\n"); /* An embedded bell character is allowed, however. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, dns_embedded_bell, sizeof(dns_embedded_bell), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (CERT_ALT_NAME_INFO *)buf; - ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n", + ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n", info->cAltEntry); ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME, - "Expected CERT_ALT_NAME_DNS_NAME, got %d\n", + "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n", info->rgAltEntry[0].dwAltNameChoice); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, url_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - /* Again, fails on WinXP with CRYPT_E_ASN1_RULE. I'm not too concerned - * about the particular failure, just that it doesn't decode. - * It succeeds on (broken) Windows versions that haven't addressed - * embedded NULLs in alternate names. - */ - ok(!ret || broken(ret), "expected failure\n"); +#if defined(__REACTOS__) && defined(_M_AMD64) + if ((GetVersion() & 0xFFFF) != 0x0006) // Next test fails on Vista x64 +#endif + ok(!ret, "expected failure\n"); } struct UnicodeExpectedError @@ -1756,17 +1697,13 @@ struct UnicodeExpectedError DWORD error; }; -static const WCHAR oneW[] = { '1',0 }; -static const WCHAR aW[] = { 'a',0 }; -static const WCHAR quoteW[] = { '"', 0 }; - static struct UnicodeExpectedError unicodeErrors[] = { - { CERT_RDN_ANY_TYPE, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_ENCODED_BLOB, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_OCTET_STRING, oneW, 0, CRYPT_E_NOT_CHAR_STRING }, - { CERT_RDN_NUMERIC_STRING, aW, 0, CRYPT_E_INVALID_NUMERIC_STRING }, - { CERT_RDN_PRINTABLE_STRING, quoteW, 0, CRYPT_E_INVALID_PRINTABLE_STRING }, - { CERT_RDN_IA5_STRING, nihongoURL, 7, CRYPT_E_INVALID_IA5_STRING }, + { CERT_RDN_ANY_TYPE, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_ENCODED_BLOB, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_OCTET_STRING, L"1", 0, CRYPT_E_NOT_CHAR_STRING }, + { CERT_RDN_NUMERIC_STRING, L"a", 0, CRYPT_E_INVALID_NUMERIC_STRING }, + { CERT_RDN_PRINTABLE_STRING, L"\"", 0, CRYPT_E_INVALID_PRINTABLE_STRING }, + { CERT_RDN_IA5_STRING, L"http://\x226f\x575b", 7, CRYPT_E_INVALID_IA5_STRING }, }; struct UnicodeExpectedResult @@ -1797,24 +1734,24 @@ static BYTE nihongoUTF8[] = { 0x0c,0x0d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0xe2,0x89,0xaf,0xe5,0x9d,0x9b }; static struct UnicodeExpectedResult unicodeResults[] = { - { CERT_RDN_NUMERIC_STRING, oneW, { sizeof(oneNumeric), oneNumeric } }, - { CERT_RDN_PRINTABLE_STRING, oneW, { sizeof(onePrintable), onePrintable } }, - { CERT_RDN_TELETEX_STRING, oneW, { sizeof(oneTeletex), oneTeletex } }, - { CERT_RDN_VIDEOTEX_STRING, oneW, { sizeof(oneVideotex), oneVideotex } }, - { CERT_RDN_IA5_STRING, oneW, { sizeof(oneIA5), oneIA5 } }, - { CERT_RDN_GRAPHIC_STRING, oneW, { sizeof(oneGraphic), oneGraphic } }, - { CERT_RDN_VISIBLE_STRING, oneW, { sizeof(oneVisible), oneVisible } }, - { CERT_RDN_UNIVERSAL_STRING, oneW, { sizeof(oneUniversal), oneUniversal } }, - { CERT_RDN_GENERAL_STRING, oneW, { sizeof(oneGeneral), oneGeneral } }, - { CERT_RDN_BMP_STRING, oneW, { sizeof(oneBMP), oneBMP } }, - { CERT_RDN_UTF8_STRING, oneW, { sizeof(oneUTF8), oneUTF8 } }, - { CERT_RDN_BMP_STRING, nihongoURL, { sizeof(nihongoBMP), nihongoBMP } }, - { CERT_RDN_UTF8_STRING, nihongoURL, { sizeof(nihongoUTF8), nihongoUTF8 } }, + { CERT_RDN_NUMERIC_STRING, L"1", { sizeof(oneNumeric), oneNumeric } }, + { CERT_RDN_PRINTABLE_STRING, L"1", { sizeof(onePrintable), onePrintable } }, + { CERT_RDN_TELETEX_STRING, L"1", { sizeof(oneTeletex), oneTeletex } }, + { CERT_RDN_VIDEOTEX_STRING, L"1", { sizeof(oneVideotex), oneVideotex } }, + { CERT_RDN_IA5_STRING, L"1", { sizeof(oneIA5), oneIA5 } }, + { CERT_RDN_GRAPHIC_STRING, L"1", { sizeof(oneGraphic), oneGraphic } }, + { CERT_RDN_VISIBLE_STRING, L"1", { sizeof(oneVisible), oneVisible } }, + { CERT_RDN_UNIVERSAL_STRING, L"1", { sizeof(oneUniversal), oneUniversal } }, + { CERT_RDN_GENERAL_STRING, L"1", { sizeof(oneGeneral), oneGeneral } }, + { CERT_RDN_BMP_STRING, L"1", { sizeof(oneBMP), oneBMP } }, + { CERT_RDN_UTF8_STRING, L"1", { sizeof(oneUTF8), oneUTF8 } }, + { CERT_RDN_BMP_STRING, L"http://\x226f\x575b", { sizeof(nihongoBMP), nihongoBMP } }, + { CERT_RDN_UTF8_STRING, L"http://\x226f\x575b", { sizeof(nihongoUTF8), nihongoUTF8 } }, }; static struct UnicodeExpectedResult unicodeWeirdness[] = { - { CERT_RDN_TELETEX_STRING, nihongoURL, { sizeof(nihongoT61), nihongoT61 } }, - { CERT_RDN_GENERAL_STRING, nihongoURL, { sizeof(nihongoGeneral), nihongoGeneral } }, + { CERT_RDN_TELETEX_STRING, L"http://\x226f\x575b", { sizeof(nihongoT61), nihongoT61 } }, + { CERT_RDN_GENERAL_STRING, L"http://\x226f\x575b", { sizeof(nihongoGeneral), nihongoGeneral } }, }; static void test_encodeUnicodeNameValue(DWORD dwEncoding) @@ -1824,59 +1761,56 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; CERT_NAME_VALUE value; - if (0) - { - /* Crashes on win9x */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Have to have a string of some sort */ value.dwValueType = 0; /* aka CERT_RDN_ANY_TYPE */ value.Value.pbData = NULL; value.Value.cbData = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, - "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); value.dwValueType = CERT_RDN_ENCODED_BLOB; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, - "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); value.dwValueType = CERT_RDN_ANY_TYPE; - value.Value.pbData = (LPBYTE)oneW; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + value.Value.pbData = (LPBYTE)L"1"; + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, - "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); - value.Value.cbData = sizeof(oneW); - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); + value.Value.cbData = sizeof(L"1"); + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, - "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); /* An encoded string with specified length isn't good enough either */ value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = oneUniversal; value.Value.cbData = sizeof(oneUniversal); - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, - "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError()); /* More failure checking */ value.Value.cbData = 0; for (i = 0; i < ARRAY_SIZE(unicodeErrors); i++) { value.Value.pbData = (LPBYTE)unicodeErrors[i].str; value.dwValueType = unicodeErrors[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == unicodeErrors[i].error, - "Value type %d: expected %08x, got %08x\n", value.dwValueType, + "Value type %ld: expected %08lx, got %08lx\n", value.dwValueType, unicodeErrors[i].error, GetLastError()); ok(size == unicodeErrors[i].errorIndex, - "Expected error index %d, got %d\n", unicodeErrors[i].errorIndex, + "Expected error index %ld, got %ld\n", unicodeErrors[i].errorIndex, size); } /* cbData can be zero if the string is NULL-terminated */ @@ -1885,17 +1819,16 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeResults[i].str; value.dwValueType = unicodeResults[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == unicodeResults[i].encoded.cbData, - "Value type %d: expected size %d, got %d\n", + "Value type %ld: expected size %ld, got %ld\n", value.dwValueType, unicodeResults[i].encoded.cbData, size); ok(!memcmp(unicodeResults[i].encoded.pbData, buf, size), - "Value type %d: unexpected value\n", value.dwValueType); + "Value type %ld: unexpected value\n", value.dwValueType); LocalFree(buf); } } @@ -1907,28 +1840,21 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str; value.dwValueType = unicodeWeirdness[i].valueType; - ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == unicodeWeirdness[i].encoded.cbData, - "Value type %d: expected size %d, got %d\n", + "Value type %ld: expected size %ld, got %ld\n", value.dwValueType, unicodeWeirdness[i].encoded.cbData, size); ok(!memcmp(unicodeWeirdness[i].encoded.pbData, buf, size), - "Value type %d: unexpected value\n", value.dwValueType); + "Value type %ld: unexpected value\n", value.dwValueType); LocalFree(buf); } } } -static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) -{ - if (n <= 0) return 0; - while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; } - return *str1 - *str2; -} - static void test_decodeUnicodeNameValue(DWORD dwEncoding) { DWORD i; @@ -1939,21 +1865,20 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, + ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, unicodeResults[i].encoded.pbData, unicodeResults[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == CRYPT_E_NOT_CHAR_STRING /* Win9x */), - "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret && buf) { PCERT_NAME_VALUE value = (PCERT_NAME_VALUE)buf; ok(value->dwValueType == unicodeResults[i].valueType, - "Expected value type %d, got %d\n", unicodeResults[i].valueType, + "Expected value type %ld, got %ld\n", unicodeResults[i].valueType, value->dwValueType); - ok(!strncmpW((LPWSTR)value->Value.pbData, unicodeResults[i].str, + ok(!wcsncmp((LPWSTR)value->Value.pbData, unicodeResults[i].str, value->Value.cbData / sizeof(WCHAR)), - "Unexpected decoded value for index %d (value type %d)\n", i, + "Unexpected decoded value for index %ld (value type %ld)\n", i, unicodeResults[i].valueType); LocalFree(buf); } @@ -1999,17 +1924,17 @@ static void test_encodeOctets(DWORD dwEncoding) blob.cbData = tests[i].decoded_size; blob.pbData = (BYTE*)tests[i].decoded; - ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); if (ret) { - ok(bufSize == tests[i].encoded_size, "[%u] buf size %u expected %u\n", + ok(bufSize == tests[i].encoded_size, "[%lu] buf size %lu expected %u\n", i, bufSize, tests[i].encoded_size); ok(buf[0] == 4, "Got unexpected type %d for octet string (expected 4)\n", buf[0]); - ok(buf[1] == tests[i].decoded_size, "[%u] Got length %d, expected %d\n", + ok(buf[1] == tests[i].decoded_size, "[%lu] Got length %d, expected %d\n", i, buf[1], tests[i].decoded_size); - ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%u] Got unexpected value\n", i); + ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%lu] Got unexpected value\n", i); LocalFree(buf); } } @@ -2071,25 +1996,25 @@ static void test_decodeOctets(DWORD dwEncoding) BOOL ret; DWORD bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, + ret = CryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (tests[i].error) { ok(!ret && GetLastError() == tests[i].error, - "[%u] CryptDecodeObjectEx returned %x(%x)\n", i, ret, GetLastError()); + "[%lu] CryptDecodeObjectEx returned %x(%lx)\n", i, ret, GetLastError()); continue; } - ok(ret, "[%u] CryptDecodeObjectEx failed: %08x\n", i, GetLastError()); + ok(ret, "[%lu] CryptDecodeObjectEx failed: %08lx\n", i, GetLastError()); ok(bufSize >= sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, - "[%u] Expected size >= %d, got %d\n", i, + "[%lu] Expected size >= %d, got %ld\n", i, (int)sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, bufSize); ok(buf != NULL, "Expected allocated buffer\n"); if (ret) { CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)buf; - ok (blob->cbData == tests[i].decoded_size, "[%u] cbData = %u\n", i, blob->cbData); + ok (blob->cbData == tests[i].decoded_size, "[%lu] cbData = %lu\n", i, blob->cbData); if (blob->cbData) ok(!memcmp(blob->pbData, tests[i].decoded, blob->cbData), "Unexpected value\n"); @@ -2137,16 +2062,16 @@ static void test_encodeBits(DWORD dwEncoding) blob.cbData = sizeof(bytesToEncode); blob.pbData = (BYTE *)bytesToEncode; blob.cUnusedBits = bits[i].cUnusedBits; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, + ret = CryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == bits[i].encoded[1] + 2, - "%d: Got unexpected size %d, expected %d\n", i, bufSize, + "%ld: Got unexpected size %ld, expected %d\n", i, bufSize, bits[i].encoded[1] + 2); ok(!memcmp(buf, bits[i].encoded, bits[i].encoded[1] + 2), - "%d: Unexpected value\n", i); + "%ld: Unexpected value\n", i); LocalFree(buf); } } @@ -2164,19 +2089,19 @@ static void test_decodeBits(DWORD dwEncoding) /* normal cases */ for (i = 0; i < ARRAY_SIZE(bits); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRYPT_BIT_BLOB *blob; ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + bits[i].cbDecoded, - "Got unexpected size %d\n", bufSize); + "Got unexpected size %ld\n", bufSize); blob = (CRYPT_BIT_BLOB *)buf; ok(blob->cbData == bits[i].cbDecoded, - "Got unexpected length %d, expected %d\n", blob->cbData, + "Got unexpected length %ld, expected %ld\n", blob->cbData, bits[i].cbDecoded); if (blob->cbData && bits[i].cbDecoded) ok(!memcmp(blob->pbData, bits[i].decoded, bits[i].cbDecoded), @@ -2187,18 +2112,18 @@ static void test_decodeBits(DWORD dwEncoding) /* special case: check that something that's valid in BER but not in DER * decodes successfully */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRYPT_BIT_BLOB *blob; ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + sizeof(berDecoded), - "Got unexpected size %d\n", bufSize); + "Got unexpected size %ld\n", bufSize); blob = (CRYPT_BIT_BLOB *)buf; ok(blob->cbData == sizeof(berDecoded), - "Got unexpected length %d\n", blob->cbData); + "Got unexpected length %ld\n", blob->cbData); if (blob->cbData) ok(*blob->pbData == berDecoded, "Unexpected value\n"); LocalFree(buf); @@ -2251,14 +2176,14 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) /* First test with the simpler info2 */ for (i = 0; i < ARRAY_SIZE(constraints2); i++) { - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == constraints2[i].encoded[1] + 2, - "Expected %d bytes, got %d\n", constraints2[i].encoded[1] + 2, + "Expected %d bytes, got %ld\n", constraints2[i].encoded[1] + 2, bufSize); ok(!memcmp(buf, constraints2[i].encoded, constraints2[i].encoded[1] + 2), "Unexpected value\n"); @@ -2269,13 +2194,12 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) info.SubjectType.cbData = 0; info.fPathLenConstraint = FALSE; info.cSubtreesConstraint = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(emptyConstraint), "Wrong size %d\n", bufSize); + ok(bufSize == sizeof(emptyConstraint), "Wrong size %ld\n", bufSize); ok(!memcmp(buf, emptyConstraint, sizeof(emptyConstraint)), "Unexpected value\n"); LocalFree(buf); @@ -2285,13 +2209,12 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) */ info.cSubtreesConstraint = 1; info.rgSubtreesConstraint = &nameBlob; - ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %d\n", bufSize); + ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %ld\n", bufSize); ok(!memcmp(buf, constraintWithDomainName, sizeof(constraintWithDomainName)), "Unexpected value\n"); LocalFree(buf); @@ -2314,10 +2237,10 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) /* First test with simpler info2 */ for (i = 0; i < ARRAY_SIZE(constraints2); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, constraints2[i].encoded, constraints2[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed for item %d: %08x\n", i, + ok(ret, "CryptDecodeObjectEx failed for item %ld: %08lx\n", i, GetLastError()); if (ret) { @@ -2325,25 +2248,23 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) (CERT_BASIC_CONSTRAINTS2_INFO *)buf; ok(!memcmp(info, &constraints2[i].info, sizeof(*info)), - "Unexpected value for item %d\n", i); + "Unexpected value for item %ld\n", i); LocalFree(buf); } } /* Check with the order of encoded elements inverted */ buf = (PBYTE)1; - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, inverted, inverted[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); ok(!buf, "Expected buf to be set to NULL\n"); /* Check with a non-DER bool */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_BASIC_CONSTRAINTS2_INFO *info = @@ -2353,18 +2274,16 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) LocalFree(buf); } /* Check with a non-basic constraints value */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, encodedCommonName, encodedCommonName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); /* Now check with the more complex CERT_BASIC_CONSTRAINTS_INFO */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, emptyConstraint, sizeof(emptyConstraint), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf; @@ -2374,10 +2293,10 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) ok(info->cSubtreesConstraint == 0, "Expected no subtree constraints\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, constraintWithDomainName, sizeof(constraintWithDomainName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf; @@ -2388,7 +2307,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) if (info->cSubtreesConstraint && info->rgSubtreesConstraint) { ok(info->rgSubtreesConstraint[0].cbData == - sizeof(encodedDomainName), "Wrong size %d\n", + sizeof(encodedDomainName), "Wrong size %ld\n", info->rgSubtreesConstraint[0].cbData); ok(!memcmp(info->rgSubtreesConstraint[0].pbData, encodedDomainName, sizeof(encodedDomainName)), "Unexpected value\n"); @@ -2402,10 +2321,10 @@ static const BYTE modulus1[] = { 0,0,0,1,1,1,1,1 }; static const BYTE modulus2[] = { 1,1,1,1,1,0,0,0 }; static const BYTE modulus3[] = { 0x80,1,1,1,1,0,0,0 }; static const BYTE modulus4[] = { 1,1,1,1,1,0,0,0x80 }; -static const BYTE mod1_encoded[] = { 0x30,0x0f,0x02,0x08,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x02,0x03,0x01,0x00,0x01 }; -static const BYTE mod2_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x01,0x00,0x01 }; -static const BYTE mod3_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x80,0x02,0x03,0x01,0x00,0x01 }; -static const BYTE mod4_encoded[] = { 0x30,0x10,0x02,0x09,0x00,0x80,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x01,0x00,0x01 }; +static const BYTE mod1_encoded[] = { 0x30,0x0f,0x02,0x08,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x01 }; +static const BYTE mod2_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x02,0x00,0x01 }; +static const BYTE mod3_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x80,0x02,0x03,0x02,0x00,0x01 }; +static const BYTE mod4_encoded[] = { 0x30,0x10,0x02,0x09,0x00,0x80,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x02,0x00,0x01 }; struct EncodedRSAPubKey { @@ -2438,73 +2357,73 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) hdr->aiKeyAlg = CALG_RSA_KEYX; rsaPubKey->magic = 0x31415352; rsaPubKey->bitlen = sizeof(modulus1) * 8; - rsaPubKey->pubexp = 65537; + rsaPubKey->pubexp = 131073; memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), modulus1, sizeof(modulus1)); - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Now with a bogus reserved field */ hdr->bType = PUBLICKEYBLOB; hdr->reserved = 1; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { ok(bufSize == rsaPubKeys[0].encoded[1] + 2, - "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize); + "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize); ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n"); LocalFree(buf); } /* Now with a bogus blob version */ hdr->reserved = 0; hdr->bVersion = 0; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { ok(bufSize == rsaPubKeys[0].encoded[1] + 2, - "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize); + "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize); ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n"); LocalFree(buf); } /* And with a bogus alg ID */ hdr->bVersion = CUR_BLOB_VERSION; hdr->aiKeyAlg = CALG_DES; - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); if (ret) { ok(bufSize == rsaPubKeys[0].encoded[1] + 2, - "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize); + "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize); ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n"); LocalFree(buf); } /* Check a couple of RSA-related OIDs */ hdr->aiKeyAlg = CALG_RSA_KEYX; - ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Finally, all valid */ hdr->aiKeyAlg = CALG_RSA_KEYX; for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen); - ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == rsaPubKeys[i].encoded[1] + 2, - "Expected size %d, got %d\n", rsaPubKeys[i].encoded[1] + 2, + "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2, bufSize); ok(!memcmp(buf, rsaPubKeys[i].encoded, bufSize), "Unexpected value\n"); @@ -2521,32 +2440,30 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) BOOL ret; /* Try with a bad length */ - ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1], CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_MORE_INPUT /* Win9x/NT4 */), - "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Try with a couple of RSA-related OIDs */ - ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Now try success cases */ for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { BLOBHEADER *hdr = (BLOBHEADER *)buf; @@ -2554,7 +2471,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) + rsaPubKeys[i].decodedModulusLen, - "Wrong size %d\n", bufSize); + "Wrong size %ld\n", bufSize); ok(hdr->bType == PUBLICKEYBLOB, "Expected type PUBLICKEYBLOB (%d), got %d\n", PUBLICKEYBLOB, hdr->bType); @@ -2566,10 +2483,10 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) ok(hdr->aiKeyAlg == CALG_RSA_KEYX, "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg); ok(rsaPubKey->magic == 0x31415352, - "Expected magic RSA1, got %08x\n", rsaPubKey->magic); + "Expected magic RSA1, got %08lx\n", rsaPubKey->magic); ok(rsaPubKey->bitlen == rsaPubKeys[i].decodedModulusLen * 8, - "Wrong bit len %d\n", rsaPubKey->bitlen); - ok(rsaPubKey->pubexp == 65537, "Expected pubexp 65537, got %d\n", + "Wrong bit len %ld\n", rsaPubKey->bitlen); + ok(rsaPubKey->pubexp == 131073, "Expected pubexp 131073, got %ld\n", rsaPubKey->pubexp); ok(!memcmp(buf + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), rsaPubKeys[i].modulus, rsaPubKeys[i].decodedModulusLen), @@ -2579,6 +2496,124 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) } } +static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding) +{ + BYTE toEncode[sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(DWORD) + sizeof(modulus1)]; + BCRYPT_RSAKEY_BLOB *hdr = (BCRYPT_RSAKEY_BLOB *)toEncode; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0, i; + BYTE pubexp[] = {0x01,0x00,0x02,0x00}; /* 131073 */ + + /* Verify that the Magic value doesn't matter */ + hdr->Magic = 1; + hdr->BitLength = sizeof(modulus1) * 8; + hdr->cbPublicExp = sizeof(pubexp); + hdr->cbModulus = sizeof(modulus1); + hdr->cbPrime1 = 0; + hdr->cbPrime2 = 0; + + /* CNG_RSA_PUBLIC_KEY_BLOB stores the exponent and modulus + * in big-endian format, so we need convert them + * from little-endian format before encoding + */ + CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB), pubexp, sizeof(pubexp)); + CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(pubexp), modulus1, sizeof(modulus1)); + + ret = CryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + + /* Finally, all valid */ + hdr->Magic = BCRYPT_RSAPUBLIC_MAGIC; + for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) + { + hdr->BitLength = rsaPubKeys[i].modulusLen * 8; + hdr->cbModulus = rsaPubKeys[i].modulusLen; + + CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(DWORD), + rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen); + + ret = CryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (ret) + { + ok(bufSize == rsaPubKeys[i].encoded[1] + 2, + "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2, + bufSize); + ok(!memcmp(buf, rsaPubKeys[i].encoded, bufSize), + "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding) +{ + DWORD i; + LPBYTE buf = NULL; + LPBYTE leModulus = NULL; + DWORD bufSize = 0; + BOOL ret; + + /* Try with a bad length */ + ret = CryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1], + CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); + /* Now try success cases */ + for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) + { + bufSize = 0; + ret = CryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB, + rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (ret) + { + BCRYPT_RSAKEY_BLOB *hdr = (BCRYPT_RSAKEY_BLOB *)buf; + BYTE pubexp[] = {0xff,0xff,0xff,0xcc}, pubexp_expected[] = {0x01,0x00,0x02}; + /* CNG_RSA_PUBLIC_KEY_BLOB stores the exponent + * in big-endian format, so we need to convert it to little-endian + */ + CRYPT_CopyReversed((BYTE *)&pubexp, buf + sizeof(BCRYPT_RSAKEY_BLOB), hdr->cbPublicExp); + ok(bufSize >= sizeof(BCRYPT_RSAKEY_BLOB) + + rsaPubKeys[i].decodedModulusLen, + "Wrong size %ld\n", bufSize); + ok(hdr->Magic == BCRYPT_RSAPUBLIC_MAGIC, + "Expected magic BCRYPT_RSAPUBLIC_MAGIC (%d), got %ld\n", BCRYPT_RSAPUBLIC_MAGIC, + hdr->Magic); + ok(hdr->BitLength == rsaPubKeys[i].decodedModulusLen * 8, + "Wrong bit len %ld\n", hdr->BitLength); + /* Windows decodes the exponent to 3 bytes, since it will fit. + * Our implementation currently unconditionally decodes to a DWORD (4 bytes) + */ + ok(hdr->cbPublicExp == 3, "Expected cbPublicExp 3, got %ld\n", hdr->cbPublicExp); + ok(hdr->cbModulus == rsaPubKeys[i].decodedModulusLen, + "Wrong modulus len %ld\n", hdr->cbModulus); + ok(hdr->cbPrime1 == 0,"Wrong cbPrime1 %ld\n", hdr->cbPrime1); + ok(hdr->cbPrime2 == 0,"Wrong cbPrime2 %ld\n", hdr->cbPrime2); + ok(!memcmp(pubexp, pubexp_expected, sizeof(pubexp_expected)), "Wrong exponent\n"); + ok(pubexp[3] == 0xcc, "Got %02x\n", pubexp[3]); + + leModulus = malloc(hdr->cbModulus); + /* + * CNG_RSA_PUBLIC_KEY_BLOB stores the modulus in big-endian format, + * so we need to convert it to little-endian + */ + CRYPT_CopyReversed(leModulus, buf + sizeof(BCRYPT_RSAKEY_BLOB) + hdr->cbPublicExp, + hdr->cbModulus); + ok(!memcmp(leModulus, + rsaPubKeys[i].modulus, rsaPubKeys[i].decodedModulusLen), + "Unexpected modulus\n"); + LocalFree(buf); + free(leModulus); + } + } +} + static const BYTE intSequence[] = { 0x30, 0x1b, 0x02, 0x01, 0x01, 0x02, 0x01, 0x7f, 0x02, 0x02, 0x00, 0x80, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x80, 0x02, 0x02, 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d }; @@ -2606,12 +2641,12 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) seq.cValue = ARRAY_SIZE(ints); seq.rgValue = blobs; - ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(intSequence), "Wrong size %d\n", bufSize); + ok(bufSize == sizeof(intSequence), "Wrong size %ld\n", bufSize); ok(!memcmp(buf, intSequence, intSequence[1] + 2), "Unexpected value\n"); LocalFree(buf); } @@ -2620,12 +2655,12 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) */ blobs[0].cbData = times[0].encodedTime[1] + 2; blobs[0].pbData = (BYTE *)times[0].encodedTime; - ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(mixedSequence), "Wrong size %d\n", bufSize); + ok(bufSize == sizeof(mixedSequence), "Wrong size %ld\n", bufSize); ok(!memcmp(buf, mixedSequence, mixedSequence[1] + 2), "Unexpected value\n"); LocalFree(buf); @@ -2638,37 +2673,37 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; DWORD i; - ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue); + ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue); for (i = 0; i < min(seq->cValue, ARRAY_SIZE(ints)); i++) { ok(seq->rgValue[i].cbData == ints[i].encoded[1] + 2, - "Expected %d bytes, got %d\n", ints[i].encoded[1] + 2, + "Expected %d bytes, got %ld\n", ints[i].encoded[1] + 2, seq->rgValue[i].cbData); ok(!memcmp(seq->rgValue[i].pbData, ints[i].encoded, ints[i].encoded[1] + 2), "Unexpected value\n"); } LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; - ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue); + ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue); /* Just check the first element since it's all that changed */ ok(seq->rgValue[0].cbData == times[0].encodedTime[1] + 2, - "Expected %d bytes, got %d\n", times[0].encodedTime[1] + 2, + "Expected %d bytes, got %ld\n", times[0].encodedTime[1] + 2, seq->rgValue[0].cbData); ok(!memcmp(seq->rgValue[0].pbData, times[0].encodedTime, times[0].encodedTime[1] + 2), "Unexpected value\n"); @@ -2717,13 +2752,13 @@ static void test_encodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, + ret = CryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == exts[i].encoded[1] + 2, - "Expected %d bytes, got %d\n", exts[i].encoded[1] + 2, bufSize); + "Expected %d bytes, got %ld\n", exts[i].encoded[1] + 2, bufSize); ok(!memcmp(buf, exts[i].encoded, exts[i].encoded[1] + 2), "Unexpected value\n"); LocalFree(buf); @@ -2741,17 +2776,17 @@ static void test_decodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_EXTENSIONS *ext = (CERT_EXTENSIONS *)buf; DWORD j; ok(ext->cExtension == exts[i].exts.cExtension, - "Expected %d extensions, see %d\n", exts[i].exts.cExtension, + "Expected %ld extensions, see %ld\n", exts[i].exts.cExtension, ext->cExtension); for (j = 0; j < min(ext->cExtension, exts[i].exts.cExtension); j++) { @@ -2767,16 +2802,16 @@ static void test_decodeExtensions(DWORD dwEncoding) } LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + buf = calloc(1, bufSize); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, buf); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(buf); } } } @@ -2855,15 +2890,14 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, &pubKeys[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(bufSize == pubKeys[i].encoded[1] + 2, - "Expected %d bytes, got %d\n", pubKeys[i].encoded[1] + 2, bufSize); + "Expected %d bytes, got %ld\n", pubKeys[i].encoded[1] + 2, bufSize); if (bufSize == pubKeys[i].encoded[1] + 2) ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2), "Unexpected value\n"); @@ -2880,14 +2914,14 @@ static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected, got->Algorithm.pszObjId); ok(expected->Algorithm.Parameters.cbData == got->Algorithm.Parameters.cbData, - "Expected parameters of %d bytes, got %d\n", + "Expected parameters of %ld bytes, got %ld\n", expected->Algorithm.Parameters.cbData, got->Algorithm.Parameters.cbData); if (expected->Algorithm.Parameters.cbData) ok(!memcmp(expected->Algorithm.Parameters.pbData, got->Algorithm.Parameters.pbData, got->Algorithm.Parameters.cbData), "Unexpected algorithm parameters\n"); ok(expected->PublicKey.cbData == got->PublicKey.cbData, - "Expected public key of %d bytes, got %d\n", + "Expected public key of %ld bytes, got %ld\n", expected->PublicKey.cbData, got->PublicKey.cbData); if (expected->PublicKey.cbData) ok(!memcmp(expected->PublicKey.pbData, got->PublicKey.pbData, @@ -2908,10 +2942,10 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(pubKeys); i++) { /* The NULL form decodes to the decoded member */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { comparePublicKeyInfo(&pubKeys[i].decoded, @@ -2919,10 +2953,10 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) LocalFree(buf); } /* The non-NULL form decodes to the original */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { comparePublicKeyInfo(&pubKeys[i].info, (CERT_PUBLIC_KEY_INFO *)buf); @@ -2930,13 +2964,11 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) } } /* Test with bogus (not valid DER) parameters */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, bogusPubKeyInfo, bogusPubKeyInfo[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); } static const BYTE v1Cert[] = { 0x30, 0x33, 0x02, 0x00, 0x30, 0x02, 0x06, 0x00, @@ -3058,57 +3090,52 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) static char oid_subject_key_identifier[] = szOID_SUBJECT_KEY_IDENTIFIER; CERT_EXTENSION ext; - if (0) - { - /* Test with NULL pvStructInfo (crashes on win9x) */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } - /* Test with a V1 cert */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + + /* Test with a V1 cert */ + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == v1Cert[1] + 2, "Expected size %d, got %d\n", + ok(size == v1Cert[1] + 2, "Expected size %d, got %ld\n", v1Cert[1] + 2, size); ok(!memcmp(buf, v1Cert, size), "Got unexpected value\n"); LocalFree(buf); } /* Test v2 cert */ info.dwVersion = CERT_V2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v2Cert), "Wrong size %d\n", size); + ok(size == sizeof(v2Cert), "Wrong size %ld\n", size); ok(!memcmp(buf, v2Cert, size), "Got unexpected value\n"); LocalFree(buf); } /* Test v3 cert */ info.dwVersion = CERT_V3; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v3Cert), "Wrong size %d\n", size); + ok(size == sizeof(v3Cert), "Wrong size %ld\n", size); ok(!memcmp(buf, v3Cert, size), "Got unexpected value\n"); LocalFree(buf); } /* A v4 cert? */ info.dwVersion = 3; /* Not a typo, CERT_V3 is 2 */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(v4Cert), "Wrong size %d\n", size); + ok(size == sizeof(v4Cert), "Wrong size %ld\n", size); ok(!memcmp(buf, v4Cert, size), "Unexpected value\n"); LocalFree(buf); } @@ -3118,24 +3145,23 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.dwVersion = CERT_V1; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */, - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CertWithConstraints), "Wrong size %d\n", size); + ok(size == sizeof(v1CertWithConstraints), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CertWithConstraints, size), "Got unexpected value\n"); LocalFree(buf); } /* test v1 cert with a serial number */ info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(v1CertWithSerial), "Wrong size %d\n", size); + ok(size == sizeof(v1CertWithSerial), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CertWithSerial, size), "Got unexpected value\n"); LocalFree(buf); } @@ -3144,13 +3170,12 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.cExtension = 0; info.IssuerUniqueId.cbData = sizeof(serialNum); info.IssuerUniqueId.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_BAD_PTR /* Win98 */), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %d\n", size); + ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CertWithIssuerUniqueId, size), "Got unexpected value\n"); LocalFree(buf); @@ -3164,11 +3189,11 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.Issuer.pbData = (BYTE *)encodedCommonName; info.Subject.cbData = sizeof(encodedCommonName); info.Subject.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(bigCert), "Wrong size %d\n", size); + ok(size == sizeof(bigCert), "Wrong size %ld\n", size); ok(!memcmp(buf, bigCert, size), "Got unexpected value\n"); LocalFree(buf); } @@ -3176,12 +3201,12 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa; info.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey); info.SubjectPublicKeyInfo.PublicKey.pbData = (LPBYTE)aKey; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { ok(size == sizeof(v1CertWithPubKey) || - size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %d\n", size); + size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %ld\n", size); if (size == sizeof(v1CertWithPubKey)) ok(!memcmp(buf, v1CertWithPubKey, size), "Got unexpected value\n"); else if (size == sizeof(v1CertWithPubKeyNoNull)) @@ -3192,14 +3217,14 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) /* Again add an issuer unique id */ info.IssuerUniqueId.cbData = sizeof(serialNum); info.IssuerUniqueId.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId) || size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); if (size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId)) ok(!memcmp(buf, v1CertWithSubjectIssuerSerialAndIssuerUniqueId, size), "unexpected value\n"); @@ -3222,11 +3247,11 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) ext.Value.pbData = octetCommonNameValue; info.cExtension = 1; info.rgExtension = &ext; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %d\n", size); + ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CertWithSubjectKeyId, size), "Unexpected value\n"); LocalFree(buf); } @@ -3241,26 +3266,23 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) DWORD size = 0, i; /* Test with NULL pbEncoded */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError()); - if (0) - { - /* Crashes on win9x */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, - CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); + + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, + CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* The following certs all fail with CRYPT_E_ASN1_CORRUPT or * CRYPT_E_ASN1_BADTAG, because at a minimum a cert must have a non-zero * serial number, an issuer, a subject, and a public key. */ for (i = 0; i < ARRAY_SIZE(corruptCerts); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure\n"); @@ -3268,94 +3290,94 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) /* The following succeeds, even though v1 certs are not allowed to have * extensions. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithSubjectKeyId, sizeof(v1CertWithSubjectKeyId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); - ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %d\n", + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); + ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n", info->dwVersion); - ok(info->cExtension == 1, "expected 1 extension, got %d\n", + ok(info->cExtension == 1, "expected 1 extension, got %ld\n", info->cExtension); LocalFree(buf); } /* The following also succeeds, even though V1 certs are not allowed to * have issuer unique ids. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithSubjectIssuerSerialAndIssuerUniqueId, sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); - ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %d\n", + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); + ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n", info->dwVersion); ok(info->IssuerUniqueId.cbData == sizeof(serialNum), - "unexpected issuer unique id size %d\n", info->IssuerUniqueId.cbData); + "unexpected issuer unique id size %ld\n", info->IssuerUniqueId.cbData); ok(!memcmp(info->IssuerUniqueId.pbData, serialNum, sizeof(serialNum)), "unexpected issuer unique id value\n"); LocalFree(buf); } /* Now check with serial number, subject and issuer specified */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, sizeof(bigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); ok(info->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); + "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData); ok(*info->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *info->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Issuer.cbData); + "Wrong size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); ok(info->Subject.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Subject.cbData); + "Wrong size %ld\n", info->Subject.cbData); ok(!memcmp(info->Subject.pbData, encodedCommonName, info->Subject.cbData), "Unexpected subject\n"); LocalFree(buf); } /* Check again with pub key specified */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithPubKey, sizeof(v1CertWithPubKey), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); ok(info->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); + "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData); ok(*info->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *info->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Issuer.cbData); + "Wrong size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); ok(info->Subject.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Subject.cbData); + "Wrong size %ld\n", info->Subject.cbData); ok(!memcmp(info->Subject.pbData, encodedCommonName, info->Subject.cbData), "Unexpected subject\n"); ok(!strcmp(info->SubjectPublicKeyInfo.Algorithm.pszObjId, szOID_RSA_RSA), "Expected szOID_RSA_RSA, got %s\n", info->SubjectPublicKeyInfo.Algorithm.pszObjId); ok(info->SubjectPublicKeyInfo.PublicKey.cbData == sizeof(aKey), - "Wrong size %d\n", info->SubjectPublicKeyInfo.PublicKey.cbData); + "Wrong size %ld\n", info->SubjectPublicKeyInfo.PublicKey.cbData); ok(!memcmp(info->SubjectPublicKeyInfo.PublicKey.pbData, aKey, sizeof(aKey)), "Unexpected public key\n"); LocalFree(buf); @@ -3449,12 +3471,12 @@ static void test_encodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(bufSize == sizeof(signedBigCert), "Wrong size %d\n", bufSize); + ok(bufSize == sizeof(signedBigCert), "Wrong size %ld\n", bufSize); ok(!memcmp(buf, signedBigCert, bufSize), "Unexpected cert\n"); LocalFree(buf); } @@ -3466,66 +3488,66 @@ static void test_decodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_SIGNED_CONTENT_INFO *info = (CERT_SIGNED_CONTENT_INFO *)buf; ok(info->ToBeSigned.cbData == sizeof(bigCert), - "Wrong cert size %d\n", info->ToBeSigned.cbData); + "Wrong cert size %ld\n", info->ToBeSigned.cbData); ok(!memcmp(info->ToBeSigned.pbData, bigCert, info->ToBeSigned.cbData), "Unexpected cert\n"); ok(info->Signature.cbData == sizeof(hash), - "Wrong signature size %d\n", info->Signature.cbData); + "Wrong signature size %ld\n", info->Signature.cbData); ok(!memcmp(info->Signature.pbData, hash, info->Signature.cbData), "Unexpected signature\n"); LocalFree(buf); } /* A signed cert decodes as a CERT_INFO too */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); ok(info->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); + "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData); ok(*info->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *info->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Issuer.cbData); + "Wrong size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); ok(info->Subject.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Subject.cbData); + "Wrong size %ld\n", info->Subject.cbData); ok(!memcmp(info->Subject.pbData, encodedCommonName, info->Subject.cbData), "Unexpected subject\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq, sizeof(signedBigCertWithIndefiniteSeq), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_INFO *info = (CERT_INFO *)buf; - ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); + ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size); ok(info->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); + "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData); ok(*info->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *info->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Issuer.cbData); + "Wrong size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); ok(info->Subject.cbData == sizeof(encodedCommonName), - "Wrong size %d\n", info->Subject.cbData); + "Wrong size %ld\n", info->Subject.cbData); ok(!memcmp(info->Subject.pbData, encodedCommonName, info->Subject.cbData), "Unexpected subject\n"); LocalFree(buf); @@ -3559,44 +3581,44 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) DWORD size = 0; /* Test with an empty info */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with one empty dist point */ info.cDistPoint = 1; info.rgDistPoint = &point; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyDistPoint), "Wrong size %d\n", size); + ok(size == sizeof(emptyDistPoint), "Wrong size %ld\n", size); ok(!memcmp(buf, emptyDistPoint, size), "Unexpected value\n"); LocalFree(buf); } /* A dist point with an invalid name */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; entry.dwAltNameChoice = CERT_ALT_NAME_URL; - U(entry).pwszURL = (LPWSTR)nihongoURL; - U(point.DistPointName).FullName.cAltEntry = 1; - U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + entry.pwszURL = (WCHAR *)L"http://\x226f\x575b"; + point.DistPointName.FullName.cAltEntry = 1; + point.DistPointName.FullName.rgAltEntry = &entry; + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, - "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError()); /* The first invalid character is at index 7 */ ok(GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size) == 7, - "Expected invalid char at index 7, got %d\n", + "Expected invalid char at index 7, got %ld\n", GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* A dist point with (just) a valid name */ - U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + entry.pwszURL = (LPWSTR)url; + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(distPointWithUrl), "Wrong size %d\n", size); + ok(size == sizeof(distPointWithUrl), "Wrong size %ld\n", size); ok(!memcmp(buf, distPointWithUrl, size), "Unexpected value\n"); LocalFree(buf); } @@ -3604,12 +3626,12 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_NO_NAME; point.ReasonFlags.cbData = sizeof(crlReason); point.ReasonFlags.pbData = (LPBYTE)&crlReason; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(distPointWithReason), "Wrong size %d\n", size); + ok(size == sizeof(distPointWithReason), "Wrong size %ld\n", size); ok(!memcmp(buf, distPointWithReason, size), "Unexpected value\n"); LocalFree(buf); } @@ -3617,24 +3639,24 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.ReasonFlags.cbData = 0; point.CRLIssuer.cAltEntry = 1; point.CRLIssuer.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(distPointWithIssuer), "Wrong size %d\n", size); + ok(size == sizeof(distPointWithIssuer), "Wrong size %ld\n", size); ok(!memcmp(buf, distPointWithIssuer, size), "Unexpected value\n"); LocalFree(buf); } /* A dist point with both a name and an issuer */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(distPointWithUrlAndIssuer), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); ok(!memcmp(buf, distPointWithUrlAndIssuer, size), "Unexpected value\n"); LocalFree(buf); } @@ -3649,67 +3671,67 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) PCRL_DIST_POINT point; PCERT_ALT_NAME_ENTRY entry; - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, emptyDistPoint, emptyDistPoint[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (PCRL_DIST_POINTS_INFO)buf; ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT), - "Wrong size %d\n", size); - ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n", + "Wrong size %ld\n", size); + ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n", info->cDistPoint); point = info->rgDistPoint; ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_NO_NAME, - "Expected CRL_DIST_POINT_NO_NAME, got %d\n", + "Expected CRL_DIST_POINT_NO_NAME, got %ld\n", point->DistPointName.dwDistPointNameChoice); ok(point->ReasonFlags.cbData == 0, "Expected no reason\n"); ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrl, distPointWithUrl[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (PCRL_DIST_POINTS_INFO)buf; ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT), - "Wrong size %d\n", size); - ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n", + "Wrong size %ld\n", size); + ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n", info->cDistPoint); point = info->rgDistPoint; ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_FULL_NAME, - "Expected CRL_DIST_POINT_FULL_NAME, got %d\n", + "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n", point->DistPointName.dwDistPointNameChoice); - ok(U(point->DistPointName).FullName.cAltEntry == 1, - "Expected 1 name entry, got %d\n", - U(point->DistPointName).FullName.cAltEntry); - entry = U(point->DistPointName).FullName.rgAltEntry; + ok(point->DistPointName.FullName.cAltEntry == 1, + "Expected 1 name entry, got %ld\n", + point->DistPointName.FullName.cAltEntry); + entry = point->DistPointName.FullName.rgAltEntry; ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL, - "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice); - ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n"); + "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice); + ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n"); ok(point->ReasonFlags.cbData == 0, "Expected no reason\n"); ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithReason, distPointWithReason[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (PCRL_DIST_POINTS_INFO)buf; ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT), - "Wrong size %d\n", size); - ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n", + "Wrong size %ld\n", size); + ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n", info->cDistPoint); point = info->rgDistPoint; ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_NO_NAME, - "Expected CRL_DIST_POINT_NO_NAME, got %d\n", + "Expected CRL_DIST_POINT_NO_NAME, got %ld\n", point->DistPointName.dwDistPointNameChoice); ok(point->ReasonFlags.cbData == sizeof(crlReason), "Expected reason length\n"); @@ -3718,50 +3740,50 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { info = (PCRL_DIST_POINTS_INFO)buf; ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT), - "Wrong size %d\n", size); - ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n", + "Wrong size %ld\n", size); + ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n", info->cDistPoint); point = info->rgDistPoint; ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_FULL_NAME, - "Expected CRL_DIST_POINT_FULL_NAME, got %d\n", + "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n", point->DistPointName.dwDistPointNameChoice); - ok(U(point->DistPointName).FullName.cAltEntry == 1, - "Expected 1 name entry, got %d\n", - U(point->DistPointName).FullName.cAltEntry); - entry = U(point->DistPointName).FullName.rgAltEntry; + ok(point->DistPointName.FullName.cAltEntry == 1, + "Expected 1 name entry, got %ld\n", + point->DistPointName.FullName.cAltEntry); + entry = point->DistPointName.FullName.rgAltEntry; ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL, - "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice); - ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n"); + "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice); + ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n"); ok(point->ReasonFlags.cbData == 0, "Expected no reason\n"); ok(point->CRLIssuer.cAltEntry == 1, - "Expected 1 issuer entry, got %d\n", point->CRLIssuer.cAltEntry); + "Expected 1 issuer entry, got %ld\n", point->CRLIssuer.cAltEntry); entry = point->CRLIssuer.rgAltEntry; ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL, - "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice); - ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n"); + "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice); + ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + buf = calloc(1, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0, NULL, buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, buf); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(buf); } } @@ -3779,66 +3801,61 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) CRL_ISSUING_DIST_POINT point = { { 0 } }; CERT_ALT_NAME_ENTRY entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_ISSUING_DIST_POINT encode support\n"); - return; - } ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "Unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "Unexpected value\n"); LocalFree(buf); } /* nonsensical flags */ point.fOnlyContainsUserCerts = TRUE; point.fOnlyContainsCACerts = TRUE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(badFlagsIDP), "Unexpected size %d\n", size); + ok(size == sizeof(badFlagsIDP), "Unexpected size %ld\n", size); ok(!memcmp(buf, badFlagsIDP, size), "Unexpected value\n"); LocalFree(buf); } /* unimplemented name type */ point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE; point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_ISSUER_RDN_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* empty name */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; - U(point.DistPointName).FullName.cAltEntry = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + point.DistPointName.FullName.cAltEntry = 0; + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyNameIDP), "Unexpected size %d\n", size); + ok(size == sizeof(emptyNameIDP), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptyNameIDP, size), "Unexpected value\n"); LocalFree(buf); } /* name with URL entry */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; - U(entry).pwszURL = (LPWSTR)url; - U(point.DistPointName).FullName.cAltEntry = 1; - U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + entry.pwszURL = (LPWSTR)url; + point.DistPointName.FullName.cAltEntry = 1; + point.DistPointName.FullName.rgAltEntry = &entry; + ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(urlIDP), "Unexpected size %d\n", size); + ok(size == sizeof(urlIDP), "Unexpected size %ld\n", size); ok(!memcmp(buf, urlIDP, size), "Unexpected value\n"); LocalFree(buf); } @@ -3848,7 +3865,7 @@ static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected, const CERT_ALT_NAME_ENTRY *got) { ok(expected->dwAltNameChoice == got->dwAltNameChoice, - "Expected name choice %d, got %d\n", expected->dwAltNameChoice, + "Expected name choice %ld, got %ld\n", expected->dwAltNameChoice, got->dwAltNameChoice); if (expected->dwAltNameChoice == got->dwAltNameChoice) { @@ -3859,19 +3876,19 @@ static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected, case CERT_ALT_NAME_EDI_PARTY_NAME: case CERT_ALT_NAME_URL: case CERT_ALT_NAME_REGISTERED_ID: - ok((!U(*expected).pwszURL && !U(*got).pwszURL) || - (!U(*expected).pwszURL && !lstrlenW(U(*got).pwszURL)) || - (!U(*got).pwszURL && !lstrlenW(U(*expected).pwszURL)) || - !lstrcmpW(U(*expected).pwszURL, U(*got).pwszURL), + ok((!expected->pwszURL && !got->pwszURL) || + (!expected->pwszURL && !lstrlenW(got->pwszURL)) || + (!got->pwszURL && !lstrlenW(expected->pwszURL)) || + !lstrcmpW(expected->pwszURL, got->pwszURL), "Unexpected name\n"); break; case CERT_ALT_NAME_X400_ADDRESS: case CERT_ALT_NAME_DIRECTORY_NAME: case CERT_ALT_NAME_IP_ADDRESS: - ok(U(*got).IPAddress.cbData == U(*expected).IPAddress.cbData, - "Unexpected IP address length %d\n", U(*got).IPAddress.cbData); - ok(!memcmp(U(*got).IPAddress.pbData, U(*expected).IPAddress.pbData, - U(*got).IPAddress.cbData), "Unexpected value\n"); + ok(got->IPAddress.cbData == expected->IPAddress.cbData, + "Unexpected IP address length %ld\n", got->IPAddress.cbData); + ok(!memcmp(got->IPAddress.pbData, expected->IPAddress.pbData, + got->IPAddress.cbData), "Unexpected value\n"); break; } } @@ -3882,7 +3899,7 @@ static void compareAltNameInfo(const CERT_ALT_NAME_INFO *expected, { DWORD i; - ok(expected->cAltEntry == got->cAltEntry, "Expected %d entries, got %d\n", + ok(expected->cAltEntry == got->cAltEntry, "Expected %ld entries, got %ld\n", expected->cAltEntry, got->cAltEntry); for (i = 0; i < min(expected->cAltEntry, got->cAltEntry); i++) compareAltNameEntry(&expected->rgAltEntry[i], &got->rgAltEntry[i]); @@ -3892,9 +3909,9 @@ static void compareDistPointName(const CRL_DIST_POINT_NAME *expected, const CRL_DIST_POINT_NAME *got) { ok(got->dwDistPointNameChoice == expected->dwDistPointNameChoice, - "Unexpected name choice %d\n", got->dwDistPointNameChoice); + "Unexpected name choice %ld\n", got->dwDistPointNameChoice); if (got->dwDistPointNameChoice == CRL_DIST_POINT_FULL_NAME) - compareAltNameInfo(&(U(*expected).FullName), &(U(*got).FullName)); + compareAltNameInfo(&(expected->FullName), &(got->FullName)); } static void compareCRLIssuingDistPoints(const CRL_ISSUING_DIST_POINT *expected, @@ -3918,53 +3935,48 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) DWORD size = 0; CRL_ISSUING_DIST_POINT point = { { 0 } }; - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_ISSUING_DIST_POINT decode support\n"); - return; - } - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, badFlagsIDP, badFlagsIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { point.fOnlyContainsUserCerts = point.fOnlyContainsCACerts = TRUE; compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptyNameIDP, emptyNameIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE; point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; - U(point.DistPointName).FullName.cAltEntry = 0; + point.DistPointName.FullName.cAltEntry = 0; compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, urlIDP, urlIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_ALT_NAME_ENTRY entry; entry.dwAltNameChoice = CERT_ALT_NAME_URL; - U(entry).pwszURL = (LPWSTR)url; - U(point.DistPointName).FullName.cAltEntry = 1; - U(point.DistPointName).FullName.rgAltEntry = &entry; + entry.pwszURL = (LPWSTR)url; + point.DistPointName.FullName.cAltEntry = 1; + point.DistPointName.FullName.rgAltEntry = &entry; compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } @@ -4024,25 +4036,23 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) CRL_ENTRY entry = { { 0 }, { 0 }, 0, 0 }; /* Test with a V1 CRL */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CRL), "Wrong size %d\n", size); + ok(size == sizeof(v1CRL), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRL, size), "Got unexpected value\n"); LocalFree(buf); } /* Test v2 CRL */ info.dwVersion = CRL_V2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == v2CRL[1] + 2, "Expected size %d, got %d\n", + ok(size == v2CRL[1] + 2, "Expected size %d, got %ld\n", v2CRL[1] + 2, size); ok(!memcmp(buf, v2CRL, size), "Got unexpected value\n"); LocalFree(buf); @@ -4051,33 +4061,32 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) info.dwVersion = CRL_V1; info.Issuer.cbData = sizeof(encodedCommonName); info.Issuer.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CRLWithIssuer), "Wrong size %d\n", size); + ok(size == sizeof(v1CRLWithIssuer), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRLWithIssuer, size), "Got unexpected value\n"); LocalFree(buf); } - if (0) - { - /* v1 CRL with a name and a NULL entry pointer (crashes on win9x) */ - info.cCRLEntry = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - } + + /* v1 CRL with a name and a NULL entry pointer */ + info.cCRLEntry = 1; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* now set an empty entry */ info.cCRLEntry = 1; info.rgCRLEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { ok(size == sizeof(v1CRLWithIssuerAndEmptyEntry), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRLWithIssuerAndEmptyEntry, size), "Got unexpected value\n"); LocalFree(buf); @@ -4085,12 +4094,12 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with a serial number */ entry.SerialNumber.cbData = sizeof(serialNum); entry.SerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { ok(size == sizeof(v1CRLWithIssuerAndEntry), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRLWithIssuerAndEntry, size), "Got unexpected value\n"); LocalFree(buf); @@ -4098,12 +4107,12 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with an extension */ entry.cExtension = 1; entry.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %d\n", size); + ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRLWithEntryExt, size), "Got unexpected value\n"); LocalFree(buf); } @@ -4111,24 +4120,24 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) entry.cExtension = 0; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v1CRLWithExt), "Wrong size %d\n", size); + ok(size == sizeof(v1CRLWithExt), "Wrong size %ld\n", size); ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n"); LocalFree(buf); } /* a v2 CRL with an extension, this time non-critical */ info.dwVersion = CRL_V2; info.rgExtension = &nonCriticalExt; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(v2CRLWithExt), "Wrong size %d\n", size); + ok(size == sizeof(v2CRLWithExt), "Wrong size %ld\n", size); ok(!memcmp(buf, v2CRLWithExt, size), "Got unexpected value\n"); LocalFree(buf); } @@ -4688,139 +4697,135 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(corruptCRLs); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); } /* at a minimum, a CRL must contain an issuer: */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuer, v1CRLWithIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; - ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size); - ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %d\n", + ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size); + ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %ld\n", info->cCRLEntry); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong issuer size %d\n", info->Issuer.cbData); + "Wrong issuer size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); LocalFree(buf); } /* check decoding with an empty CRL entry */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEmptyEntry, v1CRLWithIssuerAndEmptyEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */ || - GetLastError() == CRYPT_E_BAD_ENCODE /* Win8 */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || GetLastError() == CRYPT_E_BAD_ENCODE), + "Expected CRYPT_E_ASN1_CORRUPT or CRYPT_E_BAD_ENCODE, got %08lx\n", GetLastError()); /* with a real CRL entry */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEntry, v1CRLWithIssuerAndEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; CRL_ENTRY *entry; - ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size); - ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %d\n", + ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size); + ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n", info->cCRLEntry); ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n"); entry = info->rgCRLEntry; ok(entry->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", + "Expected serial number size 1, got %ld\n", entry->SerialNumber.cbData); ok(*entry->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *entry->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong issuer size %d\n", info->Issuer.cbData); + "Wrong issuer size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); LocalFree(buf); } /* a real CRL from verisign that has extensions */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; - ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size); - ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %d\n", + ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size); + ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %ld\n", info->cCRLEntry); ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n"); - ok(info->cExtension == 2, "Expected 2 extensions, got %d\n", + ok(info->cExtension == 2, "Expected 2 extensions, got %ld\n", info->cExtension); LocalFree(buf); } /* another real CRL from verisign that has lots of entries */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRLWithLotsOfEntries, sizeof(verisignCRLWithLotsOfEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; - ok(size >= sizeof(CRL_INFO), "Got size %d\n", size); - ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %d\n", + ok(size >= sizeof(CRL_INFO), "Got size %ld\n", size); + ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %ld\n", info->cCRLEntry); - ok(info->cExtension == 0, "Expected 0 extensions, got %d\n", + ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n", info->cExtension); LocalFree(buf); } /* and finally, with an extension */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; CRL_ENTRY *entry; - ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size); - ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %d\n", + ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size); + ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n", info->cCRLEntry); ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n"); entry = info->rgCRLEntry; ok(entry->SerialNumber.cbData == 1, - "Expected serial number size 1, got %d\n", + "Expected serial number size 1, got %ld\n", entry->SerialNumber.cbData); ok(*entry->SerialNumber.pbData == *serialNum, "Expected serial number %d, got %d\n", *serialNum, *entry->SerialNumber.pbData); ok(info->Issuer.cbData == sizeof(encodedCommonName), - "Wrong issuer size %d\n", info->Issuer.cbData); + "Wrong issuer size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), "Unexpected issuer\n"); - ok(info->cExtension == 1, "Expected 1 extensions, got %d\n", + ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n", info->cExtension); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CRL_INFO *info = (CRL_INFO *)buf; - ok(info->cExtension == 1, "Expected 1 extensions, got %d\n", + ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n", info->cExtension); LocalFree(buf); } @@ -4842,24 +4847,24 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding) /* Test with empty usage */ usage.cUsageIdentifier = 0; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "Wrong size %d\n", size); + ok(size == sizeof(emptySequence), "Wrong size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "Got unexpected value\n"); LocalFree(buf); } /* Test with a few usages */ usage.cUsageIdentifier = ARRAY_SIZE(keyUsages); usage.rgpszUsageIdentifier = (LPSTR *)keyUsages; - ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(encodedUsage), "Wrong size %d\n", size); + ok(size == sizeof(encodedUsage), "Wrong size %ld\n", size); ok(!memcmp(buf, encodedUsage, size), "Got unexpected value\n"); LocalFree(buf); } @@ -4871,49 +4876,49 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf; ok(size >= sizeof(CERT_ENHKEY_USAGE), - "Wrong size %d\n", size); - ok(usage->cUsageIdentifier == 0, "Expected 0 CRL entries, got %d\n", + "Wrong size %ld\n", size); + ok(usage->cUsageIdentifier == 0, "Expected 0 CRL entries, got %ld\n", usage->cUsageIdentifier); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf; DWORD i; ok(size >= sizeof(CERT_ENHKEY_USAGE), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); ok(usage->cUsageIdentifier == ARRAY_SIZE(keyUsages), - "Wrong CRL entries count %d\n", usage->cUsageIdentifier); + "Wrong CRL entries count %ld\n", usage->cUsageIdentifier); for (i = 0; i < usage->cUsageIdentifier; i++) ok(!strcmp(usage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected OID %s, got %s\n", keyUsages[i], usage->rgpszUsageIdentifier[i]); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + buf = calloc(1, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, buf); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(buf); } } @@ -4933,24 +4938,24 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) DWORD size = 0; /* Test with empty id */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "Unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "Unexpected value\n"); LocalFree(buf); } /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n", size); + ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n"); LocalFree(buf); } @@ -4958,12 +4963,12 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.KeyId.cbData = 0; info.CertIssuer.cbData = sizeof(encodedCommonName); info.CertIssuer.pbData = (BYTE *)encodedCommonName; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %d\n", + ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithIssuer, size), "Unexpected value\n"); LocalFree(buf); @@ -4972,12 +4977,12 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.CertIssuer.cbData = 0; info.CertSerialNumber.cbData = sizeof(serialNum); info.CertSerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n", + ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n"); LocalFree(buf); @@ -4990,30 +4995,30 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n"); ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n"); ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)), @@ -5022,15 +5027,15 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithIssuer, sizeof(authorityKeyIdWithIssuer), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->CertIssuer.cbData == sizeof(encodedCommonName), @@ -5040,15 +5045,15 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n"); @@ -5073,24 +5078,24 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) DWORD size = 0; /* Test with empty id */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "Unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "Unexpected value\n"); LocalFree(buf); } /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n", + ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n"); LocalFree(buf); @@ -5099,19 +5104,19 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.KeyId.cbData = 0; info.AuthorityCertIssuer.cAltEntry = 1; info.AuthorityCertIssuer.rgAltEntry = &entry; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* With an issuer name */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; - U(entry).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + entry.pwszURL = (LPWSTR)url; + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %d\n", + ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithIssuerUrl, size), "Unexpected value\n"); @@ -5121,12 +5126,12 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.AuthorityCertIssuer.cAltEntry = 0; info.AuthorityCertSerialNumber.cbData = sizeof(serialNum); info.AuthorityCertSerialNumber.pbData = (BYTE *)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n", + ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n", size); ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n"); LocalFree(buf); @@ -5139,15 +5144,15 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->AuthorityCertIssuer.cAltEntry == 0, @@ -5156,15 +5161,15 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n"); ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)), @@ -5175,38 +5180,38 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithIssuerUrl, sizeof(authorityKeyIdWithIssuerUrl), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->AuthorityCertIssuer.cAltEntry == 1, - "Expected 1 issuer entry, got %d\n", + "Expected 1 issuer entry, got %ld\n", info->AuthorityCertIssuer.cAltEntry); ok(info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice == - CERT_ALT_NAME_URL, "Expected CERT_ALT_NAME_URL, got %d\n", + CERT_ALT_NAME_URL, "Expected CERT_ALT_NAME_URL, got %ld\n", info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice); - ok(!lstrcmpW(U(info->AuthorityCertIssuer.rgAltEntry[0]).pwszURL, + ok(!lstrcmpW(info->AuthorityCertIssuer.rgAltEntry[0].pwszURL, url), "Unexpected URL\n"); ok(info->AuthorityCertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf; - ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n", + ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n", size); ok(info->KeyId.cbData == 0, "Expected no key id\n"); ok(info->AuthorityCertIssuer.cAltEntry == 0, @@ -5241,12 +5246,12 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) aia.cAccDescr = 0; aia.rgAccDescr = NULL; /* Having no access descriptions is allowed */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5254,26 +5259,25 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) /* It can't have an empty access method */ aia.cAccDescr = 1; aia.rgAccDescr = accessDescription; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); /* It can't have an empty location */ accessDescription[0].pszAccessMethod = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL; - U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url; + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %d\n", + ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %ld\n", size); ok(!memcmp(buf, authorityInfoAccessWithUrl, size), "unexpected value\n"); @@ -5281,20 +5285,17 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding) buf = NULL; } accessDescription[1].pszAccessMethod = oid2; - accessDescription[1].AccessLocation.dwAltNameChoice = - CERT_ALT_NAME_IP_ADDRESS; - U(accessDescription[1].AccessLocation).IPAddress.cbData = - sizeof(encodedIPAddr); - U(accessDescription[1].AccessLocation).IPAddress.pbData = - (LPBYTE)encodedIPAddr; + accessDescription[1].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; + accessDescription[1].AccessLocation.IPAddress.cbData = sizeof(encodedIPAddr); + accessDescription[1].AccessLocation.IPAddress.pbData = (LPBYTE)encodedIPAddr; aia.cAccDescr = 2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, + ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(authorityInfoAccessWithUrlAndIPAddr), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, authorityInfoAccessWithUrlAndIPAddr, size), "unexpected value\n"); LocalFree(buf); @@ -5309,12 +5310,12 @@ static void compareAuthorityInfoAccess(LPCSTR header, DWORD i; ok(expected->cAccDescr == got->cAccDescr, - "%s: expected %d access descriptions, got %d\n", header, + "%s: expected %ld access descriptions, got %ld\n", header, expected->cAccDescr, got->cAccDescr); for (i = 0; i < expected->cAccDescr; i++) { ok(!strcmp(expected->rgAccDescr[i].pszAccessMethod, - got->rgAccDescr[i].pszAccessMethod), "%s[%d]: expected %s, got %s\n", + got->rgAccDescr[i].pszAccessMethod), "%s[%ld]: expected %s, got %s\n", header, i, expected->rgAccDescr[i].pszAccessMethod, got->rgAccDescr[i].pszAccessMethod); compareAltNameEntry(&expected->rgAccDescr[i].AccessLocation, @@ -5330,10 +5331,10 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { CERT_AUTHORITY_INFO_ACCESS aia = { 0, NULL }; @@ -5343,10 +5344,10 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { CERT_ACCESS_DESCRIPTION accessDescription; @@ -5354,7 +5355,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) accessDescription.pszAccessMethod = oid1; accessDescription.AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL; - U(accessDescription.AccessLocation).pwszURL = (LPWSTR)url; + accessDescription.AccessLocation.pwszURL = (LPWSTR)url; aia.cAccDescr = 1; aia.rgAccDescr = &accessDescription; compareAuthorityInfoAccess("AIA with URL", &aia, @@ -5362,11 +5363,11 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { CERT_ACCESS_DESCRIPTION accessDescription[2]; @@ -5374,14 +5375,11 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) accessDescription[0].pszAccessMethod = oid1; accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL; - U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url; + accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url; accessDescription[1].pszAccessMethod = oid2; - accessDescription[1].AccessLocation.dwAltNameChoice = - CERT_ALT_NAME_IP_ADDRESS; - U(accessDescription[1].AccessLocation).IPAddress.cbData = - sizeof(encodedIPAddr); - U(accessDescription[1].AccessLocation).IPAddress.pbData = - (LPBYTE)encodedIPAddr; + accessDescription[1].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; + accessDescription[1].AccessLocation.IPAddress.cbData = sizeof(encodedIPAddr); + accessDescription[1].AccessLocation.IPAddress.pbData = (LPBYTE)encodedIPAddr; aia.cAccDescr = 2; aia.rgAccDescr = accessDescription; compareAuthorityInfoAccess("AIA with URL and IP addr", &aia, @@ -5389,18 +5387,18 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) LocalFree(buf); buf = NULL; } - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); + buf = calloc(1, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, + ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, buf); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); + free(buf); } } @@ -5459,23 +5457,23 @@ static void test_encodeCTL(DWORD dwEncoding) CRYPT_ATTR_BLOB value1, value2; memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyCTL), "unexpected size %d\n", size); + ok(size == sizeof(emptyCTL), "unexpected size %ld\n", size); ok(!memcmp(buf, emptyCTL, size), "unexpected value\n"); LocalFree(buf); buf = NULL; } info.dwVersion = 1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %d\n", size); + ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %ld\n", size); ok(!memcmp(buf, emptyCTLWithVersion1, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5483,12 +5481,12 @@ static void test_encodeCTL(DWORD dwEncoding) info.dwVersion = 0; info.SubjectUsage.cUsageIdentifier = 1; info.SubjectUsage.rgpszUsageIdentifier = &pOid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %d\n", + ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithUsageIdentifier, size), "unexpected value\n"); LocalFree(buf); @@ -5497,12 +5495,12 @@ static void test_encodeCTL(DWORD dwEncoding) info.SubjectUsage.cUsageIdentifier = 0; info.ListIdentifier.cbData = sizeof(serialNum); info.ListIdentifier.pbData = (LPBYTE)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithListIdentifier), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithListIdentifier), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithListIdentifier, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5510,12 +5508,12 @@ static void test_encodeCTL(DWORD dwEncoding) info.ListIdentifier.cbData = 0; info.SequenceNumber.cbData = sizeof(serialNum); info.SequenceNumber.pbData = (LPBYTE)serialNum; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %d\n", + ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithSequenceNumber, size), "unexpected value\n"); LocalFree(buf); @@ -5523,23 +5521,23 @@ static void test_encodeCTL(DWORD dwEncoding) } info.SequenceNumber.cbData = 0; SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithThisUpdate), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithThisUpdate), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithThisUpdate, size), "unexpected value\n"); LocalFree(buf); buf = NULL; } SystemTimeToFileTime(&thisUpdate, &info.NextUpdate); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %d\n", + ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithThisAndNextUpdate, size), "unexpected value\n"); LocalFree(buf); @@ -5548,12 +5546,12 @@ static void test_encodeCTL(DWORD dwEncoding) info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0; info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0; info.SubjectAlgorithm.pszObjId = oid2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithAlgId), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithAlgId), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithAlgId, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5573,24 +5571,24 @@ static void test_encodeCTL(DWORD dwEncoding) ctlEntry[0].rgAttribute = &attr1; info.cCTLEntry = 1; info.rgCTLEntry = ctlEntry; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithBogusEntry), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithBogusEntry), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithBogusEntry, size), "unexpected value\n"); LocalFree(buf); buf = NULL; } value1.cbData = sizeof(emptySequence); value1.pbData = (LPBYTE)emptySequence; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithOneEntry), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithOneEntry), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithOneEntry, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5605,12 +5603,12 @@ static void test_encodeCTL(DWORD dwEncoding) ctlEntry[1].cAttribute = 1; ctlEntry[1].rgAttribute = &attr2; info.cCTLEntry = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(ctlWithTwoEntries), "unexpected size %d\n", size); + ok(size == sizeof(ctlWithTwoEntries), "unexpected size %ld\n", size); ok(!memcmp(buf, ctlWithTwoEntries, size), "unexpected value\n"); LocalFree(buf); buf = NULL; @@ -5623,39 +5621,39 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected, DWORD i, j, k; ok(expected->dwVersion == got->dwVersion, - "%s: expected version %d, got %d\n", header, expected->dwVersion, + "%s: expected version %ld, got %ld\n", header, expected->dwVersion, got->dwVersion); ok(expected->SubjectUsage.cUsageIdentifier == got->SubjectUsage.cUsageIdentifier, - "%s: expected %d usage identifiers, got %d\n", header, + "%s: expected %ld usage identifiers, got %ld\n", header, expected->SubjectUsage.cUsageIdentifier, got->SubjectUsage.cUsageIdentifier); for (i = 0; i < expected->SubjectUsage.cUsageIdentifier; i++) ok(!strcmp(expected->SubjectUsage.rgpszUsageIdentifier[i], got->SubjectUsage.rgpszUsageIdentifier[i]), - "%s[%d]: expected %s, got %s\n", header, i, + "%s[%ld]: expected %s, got %s\n", header, i, expected->SubjectUsage.rgpszUsageIdentifier[i], got->SubjectUsage.rgpszUsageIdentifier[i]); ok(expected->ListIdentifier.cbData == got->ListIdentifier.cbData, - "%s: expected list identifier of %d bytes, got %d\n", header, + "%s: expected list identifier of %ld bytes, got %ld\n", header, expected->ListIdentifier.cbData, got->ListIdentifier.cbData); if (expected->ListIdentifier.cbData) ok(!memcmp(expected->ListIdentifier.pbData, got->ListIdentifier.pbData, expected->ListIdentifier.cbData), "%s: unexpected list identifier value\n", header); ok(expected->SequenceNumber.cbData == got->SequenceNumber.cbData, - "%s: expected sequence number of %d bytes, got %d\n", header, + "%s: expected sequence number of %ld bytes, got %ld\n", header, expected->SequenceNumber.cbData, got->SequenceNumber.cbData); if (expected->SequenceNumber.cbData) ok(!memcmp(expected->SequenceNumber.pbData, got->SequenceNumber.pbData, expected->SequenceNumber.cbData), "%s: unexpected sequence number value\n", header); ok(!memcmp(&expected->ThisUpdate, &got->ThisUpdate, sizeof(FILETIME)), - "%s: expected this update = (%d, %d), got (%d, %d)\n", header, + "%s: expected this update = (%ld, %ld), got (%ld, %ld)\n", header, expected->ThisUpdate.dwLowDateTime, expected->ThisUpdate.dwHighDateTime, got->ThisUpdate.dwLowDateTime, got->ThisUpdate.dwHighDateTime); ok(!memcmp(&expected->NextUpdate, &got->NextUpdate, sizeof(FILETIME)), - "%s: expected next update = (%d, %d), got (%d, %d)\n", header, + "%s: expected next update = (%ld, %ld), got (%ld, %ld)\n", header, expected->NextUpdate.dwLowDateTime, expected->NextUpdate.dwHighDateTime, got->NextUpdate.dwLowDateTime, got->NextUpdate.dwHighDateTime); if (expected->SubjectAlgorithm.pszObjId && @@ -5669,7 +5667,7 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected, expected->SubjectAlgorithm.pszObjId, got->SubjectAlgorithm.pszObjId); ok(expected->SubjectAlgorithm.Parameters.cbData == got->SubjectAlgorithm.Parameters.cbData, - "%s: expected subject algorithm parameters of %d bytes, got %d\n", header, + "%s: expected subject algorithm parameters of %ld bytes, got %ld\n", header, expected->SubjectAlgorithm.Parameters.cbData, got->SubjectAlgorithm.Parameters.cbData); if (expected->SubjectAlgorithm.Parameters.cbData) @@ -5678,33 +5676,33 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected, expected->SubjectAlgorithm.Parameters.cbData), "%s: unexpected subject algorithm parameter value\n", header); ok(expected->cCTLEntry == got->cCTLEntry, - "%s: expected %d CTL entries, got %d\n", header, expected->cCTLEntry, + "%s: expected %ld CTL entries, got %ld\n", header, expected->cCTLEntry, got->cCTLEntry); for (i = 0; i < expected->cCTLEntry; i++) { ok(expected->rgCTLEntry[i].SubjectIdentifier.cbData == got->rgCTLEntry[i].SubjectIdentifier.cbData, - "%s[%d]: expected subject identifier of %d bytes, got %d\n", + "%s[%ld]: expected subject identifier of %ld bytes, got %ld\n", header, i, expected->rgCTLEntry[i].SubjectIdentifier.cbData, got->rgCTLEntry[i].SubjectIdentifier.cbData); if (expected->rgCTLEntry[i].SubjectIdentifier.cbData) ok(!memcmp(expected->rgCTLEntry[i].SubjectIdentifier.pbData, got->rgCTLEntry[i].SubjectIdentifier.pbData, expected->rgCTLEntry[i].SubjectIdentifier.cbData), - "%s[%d]: unexpected subject identifier value\n", + "%s[%ld]: unexpected subject identifier value\n", header, i); for (j = 0; j < expected->rgCTLEntry[i].cAttribute; j++) { ok(!strcmp(expected->rgCTLEntry[i].rgAttribute[j].pszObjId, got->rgCTLEntry[i].rgAttribute[j].pszObjId), - "%s[%d][%d]: expected attribute OID %s, got %s\n", header, i, j, + "%s[%ld][%ld]: expected attribute OID %s, got %s\n", header, i, j, expected->rgCTLEntry[i].rgAttribute[j].pszObjId, got->rgCTLEntry[i].rgAttribute[j].pszObjId); for (k = 0; k < expected->rgCTLEntry[i].rgAttribute[j].cValue; k++) { ok(expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData == got->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData, - "%s[%d][%d][%d]: expected value of %d bytes, got %d\n", + "%s[%ld][%ld][%ld]: expected value of %ld bytes, got %ld\n", header, i, j, k, expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData, got->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData); @@ -5713,33 +5711,33 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected, expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].pbData, got->rgCTLEntry[i].rgAttribute[j].rgValue[k].pbData, expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData), - "%s[%d][%d][%d]: unexpected value\n", + "%s[%ld][%ld][%ld]: unexpected value\n", header, i, j, k); } } } ok(expected->cExtension == got->cExtension, - "%s: expected %d extensions, got %d\n", header, expected->cExtension, + "%s: expected %ld extensions, got %ld\n", header, expected->cExtension, got->cExtension); for (i = 0; i < expected->cExtension; i++) { ok(!strcmp(expected->rgExtension[i].pszObjId, - got->rgExtension[i].pszObjId), "%s[%d]: expected %s, got %s\n", + got->rgExtension[i].pszObjId), "%s[%ld]: expected %s, got %s\n", header, i, expected->rgExtension[i].pszObjId, got->rgExtension[i].pszObjId); ok(expected->rgExtension[i].fCritical == got->rgExtension[i].fCritical, - "%s[%d]: expected fCritical = %d, got %d\n", header, i, + "%s[%ld]: expected fCritical = %d, got %d\n", header, i, expected->rgExtension[i].fCritical, got->rgExtension[i].fCritical); ok(expected->rgExtension[i].Value.cbData == got->rgExtension[i].Value.cbData, - "%s[%d]: expected extension value to have %d bytes, got %d\n", + "%s[%ld]: expected extension value to have %ld bytes, got %ld\n", header, i, expected->rgExtension[i].Value.cbData, got->rgExtension[i].Value.cbData); if (expected->rgExtension[i].Value.cbData) ok(!memcmp(expected->rgExtension[i].Value.pbData, got->rgExtension[i].Value.pbData, expected->rgExtension[i].Value.cbData), - "%s[%d]: unexpected extension value\n", header, i); + "%s[%ld]: unexpected extension value\n", header, i); } } @@ -5795,9 +5793,9 @@ static void test_decodeCTL(DWORD dwEncoding) CRYPT_ATTR_BLOB value1, value2; memset(&info, 0, sizeof(info)); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL), + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("empty CTL", &info, (CTL_INFO *)buf); @@ -5805,10 +5803,10 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } info.dwVersion = 1; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTLWithVersion1, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTLWithVersion1, sizeof(emptyCTLWithVersion1), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("v1 CTL", &info, (CTL_INFO *)buf); @@ -5818,10 +5816,10 @@ static void test_decodeCTL(DWORD dwEncoding) info.dwVersion = 0; info.SubjectUsage.cUsageIdentifier = 1; info.SubjectUsage.rgpszUsageIdentifier = &pOid1; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithUsageIdentifier, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithUsageIdentifier, sizeof(ctlWithUsageIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with usage identifier", &info, (CTL_INFO *)buf); @@ -5831,9 +5829,9 @@ static void test_decodeCTL(DWORD dwEncoding) info.SubjectUsage.cUsageIdentifier = 0; info.ListIdentifier.cbData = sizeof(serialNum); info.ListIdentifier.pbData = (LPBYTE)serialNum; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier, sizeof(ctlWithListIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with list identifier", &info, (CTL_INFO *)buf); @@ -5843,9 +5841,9 @@ static void test_decodeCTL(DWORD dwEncoding) info.ListIdentifier.cbData = 0; info.SequenceNumber.cbData = sizeof(serialNum); info.SequenceNumber.pbData = (LPBYTE)serialNum; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber, sizeof(ctlWithSequenceNumber), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with sequence number", &info, (CTL_INFO *)buf); @@ -5854,9 +5852,9 @@ static void test_decodeCTL(DWORD dwEncoding) } info.SequenceNumber.cbData = 0; SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate, sizeof(ctlWithThisUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with this update", &info, (CTL_INFO *)buf); @@ -5864,10 +5862,10 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } SystemTimeToFileTime(&thisUpdate, &info.NextUpdate); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisAndNextUpdate, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisAndNextUpdate, sizeof(ctlWithThisAndNextUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with this and next update", &info, (CTL_INFO *)buf); @@ -5879,9 +5877,9 @@ static void test_decodeCTL(DWORD dwEncoding) info.SubjectAlgorithm.pszObjId = oid2; info.SubjectAlgorithm.Parameters.cbData = sizeof(nullData); info.SubjectAlgorithm.Parameters.pbData = nullData; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId, sizeof(ctlWithAlgId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with algorithm identifier", &info, (CTL_INFO *)buf); @@ -5889,13 +5887,10 @@ static void test_decodeCTL(DWORD dwEncoding) buf = NULL; } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithBogusEntry, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithBogusEntry, sizeof(ctlWithBogusEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_MORE_INPUT), /* Win9x */ - "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08x\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || GetLastError() == CRYPT_E_ASN1_CORRUPT), + "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); info.SubjectAlgorithm.Parameters.cbData = 0; info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0; @@ -5913,9 +5908,9 @@ static void test_decodeCTL(DWORD dwEncoding) info.cCTLEntry = 1; info.rgCTLEntry = ctlEntry; SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry, sizeof(ctlWithOneEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with one entry", &info, (CTL_INFO *)buf); @@ -5932,9 +5927,9 @@ static void test_decodeCTL(DWORD dwEncoding) ctlEntry[1].cAttribute = 1; ctlEntry[1].rgAttribute = &attr2; info.cCTLEntry = 2; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries, sizeof(ctlWithTwoEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { compareCTLInfo("CTL with two entries", &info, (CTL_INFO *)buf); @@ -5943,20 +5938,16 @@ static void test_decodeCTL(DWORD dwEncoding) } /* A signed CTL isn't decodable, even if the inner content is a CTL */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTL, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTL, sizeof(signedCTL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); } static const BYTE emptyPKCSContentInfo[] = { 0x30,0x04,0x06,0x02,0x2a,0x03 }; @@ -5976,49 +5967,45 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) CRYPT_CONTENT_INFO info = { 0 }; char oid1[] = "1.2.3"; - if (0) - { - /* Crashes on win9x */ - SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); - } SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError()); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); info.pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %d\n", size); + ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptyPKCSContentInfo, size), "Unexpected value\n"); LocalFree(buf); } info.Content.pbData = bogusDER; info.Content.cbData = sizeof(bogusDER); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed; %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed; %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %d\n", size); + ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %ld\n", size); ok(!memcmp(buf, bogusPKCSContentInfo, size), "Unexpected value\n"); LocalFree(buf); } info.Content.pbData = (BYTE *)ints[0].encoded; info.Content.cbData = ints[0].encoded[1] + 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(intPKCSContentInfo), "Unexpected size %d\n", size); + ok(size == sizeof(intPKCSContentInfo), "Unexpected size %ld\n", size); ok(!memcmp(buf, intPKCSContentInfo, size), "Unexpected value\n"); LocalFree(buf); } @@ -6109,33 +6096,33 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(tests); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "[%u] CryptDecodeObjectEx failed: %x\n", i, GetLastError()); + ok(ret, "[%lu] CryptDecodeObjectEx failed: %lx\n", i, GetLastError()); if (!ret) continue; info = (CRYPT_CONTENT_INFO *)buf; - ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%u] Expected %s, got %s\n", + ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%lu] Expected %s, got %s\n", i, tests[i].obj_id, info->pszObjId); ok(info->Content.cbData == tests[i].content_size, - "[%u] Unexpected size %d expected %d\n", i, info->Content.cbData, + "[%lu] Unexpected size %ld expected %d\n", i, info->Content.cbData, tests[i].content_size); if (tests[i].content) ok(!memcmp(info->Content.pbData, tests[i].content, tests[i].content_size), - "[%u] Unexpected value\n", i); + "[%lu] Unexpected value\n", i); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, bogusPKCSContentInfo, sizeof(bogusPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as * I doubt an app depends on that. */ - ok((!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT)) || broken(ret), - "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %x\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || + GetLastError() == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); } @@ -6155,28 +6142,24 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) CRYPT_ATTR_BLOB blob; char oid[] = "1.2.3"; - if (0) - { - /* Crashes on win9x */ - SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, - CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); - } SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError()); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); attr.pszObjId = oid; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyPKCSAttr), "Unexpected size %d\n", size); + ok(size == sizeof(emptyPKCSAttr), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptyPKCSAttr, size), "Unexpected value\n"); LocalFree(buf); } @@ -6184,22 +6167,22 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) blob.pbData = bogusDER; attr.cValue = 1; attr.rgValue = &blob; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(bogusPKCSAttr), "Unexpected size %d\n", size); + ok(size == sizeof(bogusPKCSAttr), "Unexpected size %ld\n", size); ok(!memcmp(buf, bogusPKCSAttr, size), "Unexpected value\n"); LocalFree(buf); } blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(intPKCSAttr), "Unexpected size %d\n", size); + ok(size == sizeof(intPKCSAttr), "Unexpected size %ld\n", size); ok(!memcmp(buf, intPKCSAttr, size), "Unexpected value\n"); LocalFree(buf); } @@ -6212,44 +6195,42 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTE *attr; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, emptyPKCSAttr, sizeof(emptyPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { attr = (CRYPT_ATTRIBUTE *)buf; ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", attr->pszObjId); - ok(attr->cValue == 0, "Expected no value, got %d\n", attr->cValue); + ok(attr->cValue == 0, "Expected no value, got %ld\n", attr->cValue); LocalFree(buf); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, bogusPKCSAttr, sizeof(bogusPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as * I doubt an app depends on that. */ - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_MORE_INPUT /* Win9x */), - "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, or OSS_MORE_INPUT, got %x\n", + ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || GetLastError() == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, intPKCSAttr, sizeof(intPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { attr = (CRYPT_ATTRIBUTE *)buf; ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", attr->pszObjId); - ok(attr->cValue == 1, "Expected 1 value, got %d\n", attr->cValue); + ok(attr->cValue == 1, "Expected 1 value, got %ld\n", attr->cValue); ok(attr->rgValue[0].cbData == ints[0].encoded[1] + 2, - "Unexpected size %d\n", attr->rgValue[0].cbData); + "Unexpected size %ld\n", attr->rgValue[0].cbData); ok(!memcmp(attr->rgValue[0].pbData, ints[0].encoded, attr->rgValue[0].cbData), "Unexpected value\n"); LocalFree(buf); @@ -6272,29 +6253,28 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; char oid1[] = "1.2.3", oid2[] = "1.5.6"; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %d\n", size); + ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %ld\n", size); ok(!memcmp(buf, emptyPKCSAttributes, size), "Unexpected value\n"); LocalFree(buf); } attributes.cAttr = 1; attributes.rgAttr = attr; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); attr[0].pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { - ok(size == sizeof(singlePKCSAttributes), "Unexpected size %d\n", size); + ok(size == sizeof(singlePKCSAttributes), "Unexpected size %ld\n", size); ok(!memcmp(buf, singlePKCSAttributes, size), "Unexpected value\n"); LocalFree(buf); } @@ -6304,12 +6284,12 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; attributes.cAttr = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(doublePKCSAttributes), "Unexpected size %d\n", size); + ok(size == sizeof(doublePKCSAttributes), "Unexpected size %ld\n", size); ok(!memcmp(buf, doublePKCSAttributes, size), "Unexpected value\n"); LocalFree(buf); } @@ -6322,65 +6302,65 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTES *attributes; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, emptyPKCSAttributes, sizeof(emptyPKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { attributes = (CRYPT_ATTRIBUTES *)buf; - ok(attributes->cAttr == 0, "Expected no attributes, got %d\n", + ok(attributes->cAttr == 0, "Expected no attributes, got %ld\n", attributes->cAttr); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, singlePKCSAttributes, sizeof(singlePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { attributes = (CRYPT_ATTRIBUTES *)buf; - ok(attributes->cAttr == 1, "Expected 1 attribute, got %d\n", + ok(attributes->cAttr == 1, "Expected 1 attribute, got %ld\n", attributes->cAttr); ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId); ok(attributes->rgAttr[0].cValue == 0, - "Expected no attributes, got %d\n", attributes->rgAttr[0].cValue); + "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { attributes = (CRYPT_ATTRIBUTES *)buf; - ok(attributes->cAttr == 2, "Expected 2 attributes, got %d\n", + ok(attributes->cAttr == 2, "Expected 2 attributes, got %ld\n", attributes->cAttr); ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId); ok(attributes->rgAttr[0].cValue == 0, - "Expected no attributes, got %d\n", attributes->rgAttr[0].cValue); + "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue); ok(!strcmp(attributes->rgAttr[1].pszObjId, "1.5.6"), "Expected 1.5.6, got %s\n", attributes->rgAttr[1].pszObjId); ok(attributes->rgAttr[1].cValue == 1, - "Expected 1 attribute, got %d\n", attributes->rgAttr[1].cValue); + "Expected 1 attribute, got %ld\n", attributes->rgAttr[1].cValue); ok(attributes->rgAttr[1].rgValue[0].cbData == ints[0].encoded[1] + 2, - "Unexpected size %d\n", attributes->rgAttr[1].rgValue[0].cbData); + "Unexpected size %ld\n", attributes->rgAttr[1].rgValue[0].cbData); ok(!memcmp(attributes->rgAttr[1].rgValue[0].pbData, ints[0].encoded, attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); + buf = calloc(1, size); if (buf) { - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, buf); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); + free(buf); } } @@ -6402,12 +6382,12 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding) /* An empty capabilities is allowed */ capabilities.cCapability = 0; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "unexpected value\n"); LocalFree(buf); } @@ -6419,30 +6399,29 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding) capabilities.cCapability = 1; capabilities.rgCapability = capability; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); capability[0].pszObjId = oid1; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(singleCapability), "unexpected size %d\n", size); + ok(size == sizeof(singleCapability), "unexpected size %ld\n", size); ok(!memcmp(buf, singleCapability, size), "unexpected value\n"); LocalFree(buf); } capability[1].pszObjId = oid2; capability[1].Parameters.cbData = 0; capabilities.cCapability = 2; - ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(twoCapabilities), "unexpected size %d\n", size); + ok(size == sizeof(twoCapabilities), "unexpected size %ld\n", size); ok(!memcmp(buf, twoCapabilities, size), "unexpected value\n"); LocalFree(buf); } @@ -6454,24 +6433,24 @@ static void compareSMimeCapabilities(LPCSTR header, DWORD i; ok(got->cCapability == expected->cCapability, - "%s: expected %d capabilities, got %d\n", header, expected->cCapability, + "%s: expected %ld capabilities, got %ld\n", header, expected->cCapability, got->cCapability); for (i = 0; i < expected->cCapability; i++) { ok(!strcmp(expected->rgCapability[i].pszObjId, - got->rgCapability[i].pszObjId), "%s[%d]: expected %s, got %s\n", + got->rgCapability[i].pszObjId), "%s[%ld]: expected %s, got %s\n", header, i, expected->rgCapability[i].pszObjId, got->rgCapability[i].pszObjId); ok(expected->rgCapability[i].Parameters.cbData == got->rgCapability[i].Parameters.cbData, - "%s[%d]: expected %d bytes, got %d\n", header, i, + "%s[%ld]: expected %ld bytes, got %ld\n", header, i, expected->rgCapability[i].Parameters.cbData, got->rgCapability[i].Parameters.cbData); if (expected->rgCapability[i].Parameters.cbData) ok(!memcmp(expected->rgCapability[i].Parameters.pbData, got->rgCapability[i].Parameters.pbData, expected->rgCapability[i].Parameters.cbData), - "%s[%d]: unexpected value\n", header, i); + "%s[%ld]: unexpected value\n", header, i); } } @@ -6484,10 +6463,10 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) CRYPT_SMIME_CAPABILITIES capabilities, *ptr; SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { capabilities.cCapability = 0; @@ -6495,10 +6474,10 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, singleCapability, sizeof(singleCapability), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { capability[0].pszObjId = oid1; @@ -6509,10 +6488,10 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, singleCapabilitywithNULL, sizeof(singleCapabilitywithNULL), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { BYTE NULLparam[] = {0x05, 0x00}; @@ -6526,10 +6505,10 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { capability[0].Parameters.cbData = 0; @@ -6540,17 +6519,17 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) LocalFree(ptr); } SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + ptr = calloc(1, size); if (ptr) { SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, ptr); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(ptr); } } @@ -6604,16 +6583,10 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) CRYPT_ATTRIBUTE attr = { oid_common_name, 1, &commonName }; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no PKCS7_SIGNER_INFO encode support\n"); - return; - } - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* To be encoded, a signer must have an issuer at least, and the encoding * must include PKCS_7_ASN_ENCODING. (That isn't enough to be decoded, * see decoding tests.) @@ -6621,18 +6594,17 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.Issuer.cbData = sizeof(encodedCommonNameNoNull); info.Issuer.pbData = encodedCommonNameNoNull; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size); + ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size); if (size == sizeof(minimalPKCSSigner)) ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n"); else @@ -6643,18 +6615,17 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n", size); if (size == sizeof(PKCSSignerWithSerial)) ok(!memcmp(buf, PKCSSignerWithSerial, size), @@ -6666,18 +6637,17 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashAlgorithm.pszObjId = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n", size); if (size == sizeof(PKCSSignerWithHashAlgo)) ok(!memcmp(buf, PKCSSignerWithHashAlgo, size), @@ -6689,18 +6659,18 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashEncryptionAlgorithm.pszObjId = oid2; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo), - "Unexpected size %d\n", size); + "Unexpected size %ld\n", size); if (size == sizeof(PKCSSignerWithHashAndEncryptionAlgo)) ok(!memcmp(buf, PKCSSignerWithHashAndEncryptionAlgo, size), "Unexpected value\n"); @@ -6712,17 +6682,17 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.EncryptedHash.cbData = sizeof(hash); info.EncryptedHash.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n", size); if (size == sizeof(PKCSSignerWithHash)) ok(!memcmp(buf, PKCSSignerWithHash, size), @@ -6735,17 +6705,17 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.AuthAttrs.cAttr = 1; info.AuthAttrs.rgAttr = &attr; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %ld\n", size); if (size == sizeof(PKCSSignerWithAuthAttr)) ok(!memcmp(buf, PKCSSignerWithAuthAttr, size), @@ -6766,68 +6736,66 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) /* A PKCS signer can't be decoded without a serial number. */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, minimalPKCSSigner, sizeof(minimalPKCSSigner), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %x\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR), - "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull), - "Unexpected size %d\n", info->Issuer.cbData); + "Unexpected size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull, info->Issuer.cbData), "Unexpected value\n"); ok(info->SerialNumber.cbData == sizeof(serialNum), - "Unexpected size %d\n", info->SerialNumber.cbData); + "Unexpected size %ld\n", info->SerialNumber.cbData); ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { info = (CMSG_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull), - "Unexpected size %d\n", info->Issuer.cbData); + "Unexpected size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull, info->Issuer.cbData), "Unexpected value\n"); ok(info->SerialNumber.cbData == sizeof(serialNum), - "Unexpected size %d\n", info->SerialNumber.cbData); + "Unexpected size %ld\n", info->SerialNumber.cbData); ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAndEncryptionAlgo, sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { info = (CMSG_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull), - "Unexpected size %d\n", info->Issuer.cbData); + "Unexpected size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull, info->Issuer.cbData), "Unexpected value\n"); ok(info->SerialNumber.cbData == sizeof(serialNum), - "Unexpected size %d\n", info->SerialNumber.cbData); + "Unexpected size %ld\n", info->SerialNumber.cbData); ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"), @@ -6836,47 +6804,47 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHash, sizeof(PKCSSignerWithHash), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { info = (CMSG_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull), - "Unexpected size %d\n", info->Issuer.cbData); + "Unexpected size %ld\n", info->Issuer.cbData); ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull, info->Issuer.cbData), "Unexpected value\n"); ok(info->SerialNumber.cbData == sizeof(serialNum), - "Unexpected size %d\n", info->SerialNumber.cbData); + "Unexpected size %ld\n", info->SerialNumber.cbData); ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId); ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, "1.5.6"), "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId); - ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %d\n", + ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n", info->EncryptedHash.cbData); ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithAuthAttr, sizeof(PKCSSignerWithAuthAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); if (ret) { info = (CMSG_SIGNER_INFO *)buf; - ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %d\n", + ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %ld\n", info->AuthAttrs.cAttr); ok(!strcmp(info->AuthAttrs.rgAttr[0].pszObjId, szOID_COMMON_NAME), "Expected %s, got %s\n", szOID_COMMON_NAME, info->AuthAttrs.rgAttr[0].pszObjId); - ok(info->AuthAttrs.rgAttr[0].cValue == 1, "Expected 1 value, got %d\n", + ok(info->AuthAttrs.rgAttr[0].cValue == 1, "Expected 1 value, got %ld\n", info->AuthAttrs.rgAttr[0].cValue); ok(info->AuthAttrs.rgAttr[0].rgValue[0].cbData == - sizeof(encodedCommonName), "Unexpected size %d\n", + sizeof(encodedCommonName), "Unexpected size %ld\n", info->AuthAttrs.rgAttr[0].rgValue[0].cbData); ok(!memcmp(info->AuthAttrs.rgAttr[0].rgValue[0].pbData, encodedCommonName, sizeof(encodedCommonName)), "Unexpected value\n"); @@ -6897,86 +6865,75 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) static char oid1[] = "1.2.3", oid2[] = "1.5.6"; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure, got %d\n", ret); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO encode support\n"); - return; - } ok(GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "Expected failure, got %d\n", ret); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO encode support\n"); - return; - } ok(GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* To be encoded, a signer must have a valid cert ID, where a valid ID may * be a key id or an issuer serial number with at least the issuer set, and * the encoding must include PKCS_7_ASN_ENCODING. * (That isn't enough to be decoded, see decoding tests.) */ - U(info.SignerId).IssuerSerialNumber.Issuer.cbData = - sizeof(encodedCommonNameNoNull); - U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; + info.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonNameNoNull); + info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size); + ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size); ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n"); LocalFree(buf); } } - U(info.SignerId).IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); - U(info.SignerId).IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum; + info.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); + info.SignerId.IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n", size); ok(!memcmp(buf, PKCSSignerWithSerial, size), "Unexpected value\n"); LocalFree(buf); } } info.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER; - U(info.SignerId).KeyId.cbData = sizeof(serialNum); - U(info.SignerId).KeyId.pbData = (BYTE *)serialNum; + info.SignerId.KeyId.cbData = sizeof(serialNum); + info.SignerId.KeyId.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %d\n", + ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %ld\n", size); ok(!memcmp(buf, CMSSignerWithKeyId, size), "Unexpected value\n"); LocalFree(buf); @@ -6987,31 +6944,30 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) * (see RFC 3852, section 5.3.) */ info.SignerId.dwIdChoice = CERT_ID_SHA1_HASH; - U(info.SignerId).HashId.cbData = sizeof(hash); - U(info.SignerId).HashId.pbData = (BYTE *)hash; + info.SignerId.HashId.cbData = sizeof(hash); + info.SignerId.HashId.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Now with a hash algo */ info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; - U(info.SignerId).IssuerSerialNumber.Issuer.cbData = - sizeof(encodedCommonNameNoNull); - U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; + info.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonNameNoNull); + info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull; info.HashAlgorithm.pszObjId = oid1; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n", size); ok(!memcmp(buf, PKCSSignerWithHashAlgo, size), "Unexpected value\n"); @@ -7020,18 +6976,18 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) } info.HashEncryptionAlgorithm.pszObjId = oid2; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo), - "Unexpected size %d\n", size); + "Unexpected size %ld\n", size); ok(!memcmp(buf, PKCSSignerWithHashAndEncryptionAlgo, size), "Unexpected value\n"); LocalFree(buf); @@ -7040,17 +6996,17 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding) info.EncryptedHash.cbData = sizeof(hash); info.EncryptedHash.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, + ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); else { - ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError()); if (ret) { - ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n", + ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n", size); ok(!memcmp(buf, PKCSSignerWithHash, size), "Unexpected value\n"); LocalFree(buf); @@ -7068,95 +7024,90 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) /* A CMS signer can't be decoded without a serial number. */ SetLastError(0xdeadbeef); - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, minimalPKCSSigner, sizeof(minimalPKCSSigner), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret, "expected failure\n"); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no CMS_SIGNER_INFO decode support\n"); - return; - } ok(GetLastError() == CRYPT_E_ASN1_CORRUPT, - "Expected CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_CMS_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER, - "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n", + "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n", info->SignerId.dwIdChoice); - ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData == - sizeof(encodedCommonNameNoNull), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.Issuer.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData, + ok(info->SignerId.IssuerSerialNumber.Issuer.cbData == + sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.Issuer.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData, encodedCommonNameNoNull, - U(info->SignerId).IssuerSerialNumber.Issuer.cbData), + info->SignerId.IssuerSerialNumber.Issuer.cbData), "Unexpected value\n"); - ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData == - sizeof(serialNum), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData, + ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData == + sizeof(serialNum), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.SerialNumber.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_CMS_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER, - "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n", + "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n", info->SignerId.dwIdChoice); - ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData == - sizeof(encodedCommonNameNoNull), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.Issuer.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData, + ok(info->SignerId.IssuerSerialNumber.Issuer.cbData == + sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.Issuer.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData, encodedCommonNameNoNull, - U(info->SignerId).IssuerSerialNumber.Issuer.cbData), + info->SignerId.IssuerSerialNumber.Issuer.cbData), "Unexpected value\n"); - ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData == - sizeof(serialNum), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData, + ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData == + sizeof(serialNum), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.SerialNumber.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, oid1), "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHashAndEncryptionAlgo, sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_CMS_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER, - "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n", + "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n", info->SignerId.dwIdChoice); - ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData == - sizeof(encodedCommonNameNoNull), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.Issuer.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData, + ok(info->SignerId.IssuerSerialNumber.Issuer.cbData == + sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.Issuer.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData, encodedCommonNameNoNull, - U(info->SignerId).IssuerSerialNumber.Issuer.cbData), + info->SignerId.IssuerSerialNumber.Issuer.cbData), "Unexpected value\n"); - ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData == - sizeof(serialNum), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData, + ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData == + sizeof(serialNum), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.SerialNumber.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, oid1), "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId); @@ -7164,55 +7115,55 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding) "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, PKCSSignerWithHash, sizeof(PKCSSignerWithHash), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_CMS_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER, - "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n", + "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n", info->SignerId.dwIdChoice); - ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData == - sizeof(encodedCommonNameNoNull), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.Issuer.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData, + ok(info->SignerId.IssuerSerialNumber.Issuer.cbData == + sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.Issuer.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData, encodedCommonNameNoNull, - U(info->SignerId).IssuerSerialNumber.Issuer.cbData), + info->SignerId.IssuerSerialNumber.Issuer.cbData), "Unexpected value\n"); - ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData == - sizeof(serialNum), "Unexpected size %d\n", - U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData); - ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData, + ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData == + sizeof(serialNum), "Unexpected size %ld\n", + info->SignerId.IssuerSerialNumber.SerialNumber.cbData); + ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); ok(!strcmp(info->HashAlgorithm.pszObjId, oid1), "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId); ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, oid2), "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId); - ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %d\n", + ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n", info->EncryptedHash.cbData); ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)), "Unexpected value\n"); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, + ret = CryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO, CMSSignerWithKeyId, sizeof(CMSSignerWithKeyId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError()); if (ret) { info = (CMSG_CMS_SIGNER_INFO *)buf; - ok(info->dwVersion == 0, "Expected version 0, got %d\n", + ok(info->dwVersion == 0, "Expected version 0, got %ld\n", info->dwVersion); ok(info->SignerId.dwIdChoice == CERT_ID_KEY_IDENTIFIER, - "Expected CERT_ID_KEY_IDENTIFIER, got %d\n", + "Expected CERT_ID_KEY_IDENTIFIER, got %ld\n", info->SignerId.dwIdChoice); - ok(U(info->SignerId).KeyId.cbData == sizeof(serialNum), - "Unexpected size %d\n", U(info->SignerId).KeyId.cbData); - ok(!memcmp(U(info->SignerId).KeyId.pbData, serialNum, sizeof(serialNum)), + ok(info->SignerId.KeyId.cbData == sizeof(serialNum), + "Unexpected size %ld\n", info->SignerId.KeyId.cbData); + ok(!memcmp(info->SignerId.KeyId.pbData, serialNum, sizeof(serialNum)), "Unexpected value\n"); LocalFree(buf); } @@ -7247,14 +7198,9 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LPBYTE buf; DWORD size; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_NAME_CONSTRAINTS encode support\n"); - return; - } - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(emptySequence), "Unexpected size\n"); @@ -7264,14 +7210,14 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cPermittedSubtree = 1; constraints.rgPermittedSubtree = &permitted; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); permitted.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(emptyDNSPermittedConstraints), "Unexpected size\n"); @@ -7283,9 +7229,9 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cExcludedSubtree = 1; constraints.rgExcludedSubtree = &excluded; excluded.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(emptyDNSExcludedConstraints), "Unexpected size\n"); @@ -7293,10 +7239,10 @@ static void test_encodeNameConstraints(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - U(excluded.Base).pwszURL = (LPWSTR)url; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + excluded.Base.pwszURL = (LPWSTR)url; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(DNSExcludedConstraints), "Unexpected size\n"); @@ -7305,12 +7251,12 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } permitted.Base.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; - U(permitted.Base).IPAddress.cbData = sizeof(encodedIPAddr); - U(permitted.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; + permitted.Base.IPAddress.cbData = sizeof(encodedIPAddr); + permitted.Base.IPAddress.pbData = (LPBYTE)encodedIPAddr; constraints.cPermittedSubtree = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(permittedAndExcludedConstraints), @@ -7320,9 +7266,9 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } permitted.dwMinimum = 5; - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(permittedAndExcludedWithMinConstraints), @@ -7334,9 +7280,9 @@ static void test_encodeNameConstraints(DWORD dwEncoding) permitted.fMaximum = TRUE; permitted.dwMaximum = 3; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(permittedAndExcludedWithMinMaxConstraints), @@ -7388,34 +7334,29 @@ static void test_decodeNameConstraints(DWORD dwEncoding) DWORD i; CERT_NAME_CONSTRAINTS_INFO *constraints; - U(DNSSubtree.Base).pwszURL = (LPWSTR)url; - U(IPAddressSubtree.Base).IPAddress.cbData = sizeof(encodedIPAddr); - U(IPAddressSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; - U(IPAddressWithMinSubtree.Base).IPAddress.cbData = sizeof(encodedIPAddr); - U(IPAddressWithMinSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; - U(IPAddressWithMinMaxSubtree.Base).IPAddress.cbData = sizeof(encodedIPAddr); - U(IPAddressWithMinMaxSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; + DNSSubtree.Base.pwszURL = (LPWSTR)url; + IPAddressSubtree.Base.IPAddress.cbData = sizeof(encodedIPAddr); + IPAddressSubtree.Base.IPAddress.pbData = (LPBYTE)encodedIPAddr; + IPAddressWithMinSubtree.Base.IPAddress.cbData = sizeof(encodedIPAddr); + IPAddressWithMinSubtree.Base.IPAddress.pbData = (LPBYTE)encodedIPAddr; + IPAddressWithMinMaxSubtree.Base.IPAddress.cbData = sizeof(encodedIPAddr); + IPAddressWithMinMaxSubtree.Base.IPAddress.pbData = (LPBYTE)encodedIPAddr; for (i = 0; i < ARRAY_SIZE(encodedNameConstraints); i++) { DWORD size; - ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, encodedNameConstraints[i].encoded.pbData, encodedNameConstraints[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &constraints, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_NAME_CONSTRAINTS decode support\n"); - return; - } - ok(ret, "%d: CryptDecodeObjectEx failed: %08x\n", i, GetLastError()); + ok(ret, "%ld: CryptDecodeObjectEx failed: %08lx\n", i, GetLastError()); if (ret) { DWORD j; if (constraints->cPermittedSubtree != encodedNameConstraints[i].constraints.cPermittedSubtree) - fprintf(stderr, "%d: expected %u permitted, got %u\n", i, + fprintf(stderr, "%ld: expected %lu permitted, got %lu\n", i, encodedNameConstraints[i].constraints.cPermittedSubtree, constraints->cPermittedSubtree); if (constraints->cPermittedSubtree == @@ -7429,7 +7370,7 @@ static void test_decodeNameConstraints(DWORD dwEncoding) } if (constraints->cExcludedSubtree != encodedNameConstraints[i].constraints.cExcludedSubtree) - fprintf(stderr, "%d: expected %u excluded, got %u\n", i, + fprintf(stderr, "%ld: expected %lu excluded, got %lu\n", i, encodedNameConstraints[i].constraints.cExcludedSubtree, constraints->cExcludedSubtree); if (constraints->cExcludedSubtree == @@ -7446,8 +7387,6 @@ static void test_decodeNameConstraints(DWORD dwEncoding) } } -static WCHAR noticeText[] = { 'T','h','i','s',' ','i','s',' ','a',' ', - 'n','o','t','i','c','e',0 }; static const BYTE noticeWithDisplayText[] = { 0x30,0x22,0x1e,0x20,0x00,0x54,0x00,0x68,0x00,0x69,0x00,0x73,0x00,0x20,0x00, 0x69,0x00,0x73,0x00,0x20,0x00,0x61,0x00,0x20,0x00,0x6e,0x00,0x6f,0x00,0x74, @@ -7471,29 +7410,24 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) CERT_POLICY_QUALIFIER_NOTICE_REFERENCE reference; memset(¬ice, 0, sizeof(notice)); - ret = pCryptEncodeObjectEx(dwEncoding, + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE encode support\n"); - return; - } - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(emptySequence) == size, "unexpected size %d\n", size); + ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "unexpected value\n"); LocalFree(buf); } - notice.pszDisplayText = noticeText; - ret = pCryptEncodeObjectEx(dwEncoding, + notice.pszDisplayText = (WCHAR *)L"This is a notice"; + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(noticeWithDisplayText) == size, "unexpected size %d\n", size); + ok(sizeof(noticeWithDisplayText) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, noticeWithDisplayText, size), "unexpected value\n"); LocalFree(buf); } @@ -7501,13 +7435,13 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding) reference.cNoticeNumbers = 2; reference.rgNoticeNumbers = noticeNumbers; notice.pNoticeReference = &reference; - ret = pCryptEncodeObjectEx(dwEncoding, + ret = CryptEncodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, ¬ice, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(noticeWithReference) == size, "unexpected size %d\n", size); + ok(sizeof(noticeWithReference) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, noticeWithReference, size), "unexpected value\n"); LocalFree(buf); } @@ -7519,42 +7453,37 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) CERT_POLICY_QUALIFIER_USER_NOTICE *notice; DWORD size; - ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE decode support\n"); - return; - } - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(notice->pszDisplayText == NULL, "unexpected display text\n"); ok(notice->pNoticeReference == NULL, "unexpected notice reference\n"); LocalFree(notice); } - ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, noticeWithDisplayText, sizeof(noticeWithDisplayText), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(!lstrcmpW(notice->pszDisplayText, noticeText), + ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"), "unexpected display text\n"); ok(notice->pNoticeReference == NULL, "unexpected notice reference\n"); LocalFree(notice); } - ret = pCryptDecodeObjectEx(dwEncoding, + ret = CryptDecodeObjectEx(dwEncoding, X509_PKIX_POLICY_QUALIFIER_USERNOTICE, noticeWithReference, sizeof(noticeWithReference), CRYPT_DECODE_ALLOC_FLAG, NULL, ¬ice, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(!lstrcmpW(notice->pszDisplayText, noticeText), + ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"), "unexpected display text\n"); ok(notice->pNoticeReference != NULL, "expected a notice reference\n"); if (notice->pNoticeReference) @@ -7563,7 +7492,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding) "unexpected organization %s\n", notice->pNoticeReference->pszOrganization); ok(notice->pNoticeReference->cNoticeNumbers == 2, - "expected 2 notice numbers, got %d\n", + "expected 2 notice numbers, got %ld\n", notice->pNoticeReference->cNoticeNumbers); ok(notice->pNoticeReference->rgNoticeNumbers[0] == noticeNumbers[0], "unexpected notice number %d\n", @@ -7601,30 +7530,29 @@ static void test_encodeCertPolicies(DWORD dwEncoding) DWORD size; memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(emptySequence) == size, "unexpected size %d\n", size); + ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, size), "unexpected value\n"); LocalFree(buf); } memset(policy, 0, sizeof(policy)); info.cPolicyInfo = 1; info.rgPolicyInfo = policy; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x/NT4 */), - "expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); policy[0].pszPolicyIdentifier = oid_any_policy; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(policiesWithAnyPolicy) == size, "unexpected size %d\n", size); + ok(sizeof(policiesWithAnyPolicy) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, policiesWithAnyPolicy, size), "unexpected value\n"); LocalFree(buf); } @@ -7636,12 +7564,12 @@ static void test_encodeCertPolicies(DWORD dwEncoding) policy[1].cPolicyQualifier = 1; policy[1].rgPolicyQualifier = &qualifier; info.cPolicyInfo = 2; - ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(sizeof(twoPolicies) == size, "unexpected size %d\n", size); + ok(sizeof(twoPolicies) == size, "unexpected size %ld\n", size); ok(!memcmp(buf, twoPolicies, size), "unexpected value\n"); LocalFree(buf); } @@ -7653,58 +7581,58 @@ static void test_decodeCertPolicies(DWORD dwEncoding) CERT_POLICIES_INFO *info; DWORD size; - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(info->cPolicyInfo == 0, "unexpected policy info %d\n", + ok(info->cPolicyInfo == 0, "unexpected policy info %ld\n", info->cPolicyInfo); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, policiesWithAnyPolicy, sizeof(policiesWithAnyPolicy), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(info->cPolicyInfo == 1, "unexpected policy info %d\n", + ok(info->cPolicyInfo == 1, "unexpected policy info %ld\n", info->cPolicyInfo); ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy), "unexpected policy id %s\n", info->rgPolicyInfo[0].pszPolicyIdentifier); ok(info->rgPolicyInfo[0].cPolicyQualifier == 0, - "unexpected policy qualifier count %d\n", + "unexpected policy qualifier count %ld\n", info->rgPolicyInfo[0].cPolicyQualifier); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(info->cPolicyInfo == 2, "unexpected policy info %d\n", + ok(info->cPolicyInfo == 2, "unexpected policy info %ld\n", info->cPolicyInfo); ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy), "unexpected policy id %s\n", info->rgPolicyInfo[0].pszPolicyIdentifier); ok(info->rgPolicyInfo[0].cPolicyQualifier == 0, - "unexpected policy qualifier count %d\n", + "unexpected policy qualifier count %ld\n", info->rgPolicyInfo[0].cPolicyQualifier); ok(!strcmp(info->rgPolicyInfo[1].pszPolicyIdentifier, oid1), "unexpected policy id %s\n", info->rgPolicyInfo[1].pszPolicyIdentifier); ok(info->rgPolicyInfo[1].cPolicyQualifier == 1, - "unexpected policy qualifier count %d\n", + "unexpected policy qualifier count %ld\n", info->rgPolicyInfo[1].cPolicyQualifier); ok(!strcmp( info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId, oid_user_notice), "unexpected policy qualifier id %s\n", info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId); ok(info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData == - sizeof(noticeWithReference), "unexpected qualifier size %d\n", + sizeof(noticeWithReference), "unexpected qualifier size %ld\n", info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData); ok(!memcmp( info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.pbData, @@ -7712,16 +7640,16 @@ static void test_decodeCertPolicies(DWORD dwEncoding) "unexpected qualifier value\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + info = calloc(1, size); if (info) { - ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, info); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(info); } } @@ -7748,18 +7676,12 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { memset(&info, 0, sizeof(info)); - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, sizeof(emptySequence)), "unexpected value\n"); LocalFree(buf); @@ -7769,19 +7691,19 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) info.cPolicyMapping = 1; info.rgPolicyMapping = mapping; SetLastError(0xdeadbeef); - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); mapping[0].pszIssuerDomainPolicy = oid1; mapping[0].pszSubjectDomainPolicy = oid2; - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(policyMappingWithOneMapping), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, policyMappingWithOneMapping, size), "unexpected value\n"); LocalFree(buf); @@ -7789,13 +7711,13 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) mapping[1].pszIssuerDomainPolicy = oid3; mapping[1].pszSubjectDomainPolicy = oid4; info.cPolicyMapping = 2; - ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, + ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(policyMappingWithTwoMappings), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, policyMappingWithTwoMappings, size), "unexpected value\n"); LocalFree(buf); @@ -7812,30 +7734,24 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) /* Each of the mapping OIDs is equivalent, so check with all of them */ for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->cPolicyMapping == 0, - "expected 0 policy mappings, got %d\n", info->cPolicyMapping); + "expected 0 policy mappings, got %ld\n", info->cPolicyMapping); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithOneMapping, sizeof(policyMappingWithOneMapping), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->cPolicyMapping == 1, - "expected 1 policy mappings, got %d\n", info->cPolicyMapping); + "expected 1 policy mappings, got %ld\n", info->cPolicyMapping); ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"), "unexpected issuer policy %s\n", info->rgPolicyMapping[0].pszIssuerDomainPolicy); @@ -7844,14 +7760,14 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) info->rgPolicyMapping[0].pszSubjectDomainPolicy); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->cPolicyMapping == 2, - "expected 2 policy mappings, got %d\n", info->cPolicyMapping); + "expected 2 policy mappings, got %ld\n", info->cPolicyMapping); ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"), "unexpected issuer policy %s\n", info->rgPolicyMapping[0].pszIssuerDomainPolicy); @@ -7866,18 +7782,18 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) info->rgPolicyMapping[1].pszSubjectDomainPolicy); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + info = calloc(1, size); if (info) { - ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], + ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0, NULL, info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, info); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + free(info); } } } @@ -7899,18 +7815,12 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) /* Even though RFC 5280 explicitly states CAs must not issue empty * policy constraints (section 4.2.1.11), the API doesn't prevent it. */ - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptEncodeObjectEx failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy constraints support\n"); - return; - } + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(emptySequence), "unexpected size %d\n", size); + ok(size == sizeof(emptySequence), "unexpected size %ld\n", size); ok(!memcmp(buf, emptySequence, sizeof(emptySequence)), "unexpected value\n"); LocalFree(buf); @@ -7919,13 +7829,13 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) * is not, then a skip of 0 is encoded. */ info.fRequireExplicitPolicy = TRUE; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(policyConstraintsWithRequireExplicit), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, policyConstraintsWithRequireExplicit, sizeof(policyConstraintsWithRequireExplicit)), "unexpected value\n"); LocalFree(buf); @@ -7935,13 +7845,13 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) info.dwRequireExplicitPolicySkipCerts = 0; info.fInhibitPolicyMapping = TRUE; info.dwInhibitPolicyMappingSkipCerts = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(policyConstraintsWithInhibitMapping), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, policyConstraintsWithInhibitMapping, sizeof(policyConstraintsWithInhibitMapping)), "unexpected value\n"); LocalFree(buf); @@ -7949,12 +7859,12 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding) /* And with both */ info.fRequireExplicitPolicy = TRUE; info.dwRequireExplicitPolicySkipCerts = 1; - ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, + ret = CryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { - ok(size == sizeof(policyConstraintsWithBoth), "unexpected size %d\n", + ok(size == sizeof(policyConstraintsWithBoth), "unexpected size %ld\n", size); ok(!memcmp(buf, policyConstraintsWithBoth, sizeof(policyConstraintsWithBoth)), "unexpected value\n"); @@ -7971,16 +7881,10 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) /* Again, even though CAs must not issue such constraints, they can be * decoded. */ - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND), - "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("no policy mappings support\n"); - return; - } + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!info->fRequireExplicitPolicy, @@ -7989,49 +7893,49 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding) "expected implicit mapping = FALSE\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithRequireExplicit, sizeof(policyConstraintsWithRequireExplicit), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->fRequireExplicitPolicy, "expected require explicit = TRUE\n"); - ok(info->dwRequireExplicitPolicySkipCerts == 0, "expected 0, got %d\n", + ok(info->dwRequireExplicitPolicySkipCerts == 0, "expected 0, got %ld\n", info->dwRequireExplicitPolicySkipCerts); ok(!info->fInhibitPolicyMapping, "expected implicit mapping = FALSE\n"); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithInhibitMapping, sizeof(policyConstraintsWithInhibitMapping), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(!info->fRequireExplicitPolicy, "expected require explicit = FALSE\n"); ok(info->fInhibitPolicyMapping, "expected implicit mapping = TRUE\n"); - ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %d\n", + ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n", info->dwInhibitPolicyMappingSkipCerts); LocalFree(info); } - ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, + ret = CryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, policyConstraintsWithBoth, sizeof(policyConstraintsWithBoth), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { ok(info->fRequireExplicitPolicy, "expected require explicit = TRUE\n"); - ok(info->dwRequireExplicitPolicySkipCerts == 1, "expected 1, got %d\n", + ok(info->dwRequireExplicitPolicySkipCerts == 1, "expected 1, got %ld\n", info->dwRequireExplicitPolicySkipCerts); ok(info->fInhibitPolicyMapping, "expected implicit mapping = TRUE\n"); - ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %d\n", + ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n", info->dwInhibitPolicyMappingSkipCerts); LocalFree(info); } @@ -8251,19 +8155,19 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding) DWORD bufSize = 0; BOOL ret; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, rsaPrivKeyDer, sizeof(rsaPrivKeyDer)-10, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD), - "Expected CRYPT_E_ASN1_EOD, got %08x\n", + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); buf = NULL; bufSize = 0; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, + ret = CryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY, rsaPrivKeyDer, sizeof(rsaPrivKeyDer), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); if (ret) { @@ -8280,7 +8184,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding) ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) + (bitlen * 9 / 16), - "Wrong size %d\n", bufSize); + "Wrong size %ld\n", bufSize); ok(hdr->bType == PRIVATEKEYBLOB, "Expected type PRIVATEKEYBLOB (%d), got %d\n", PRIVATEKEYBLOB, @@ -8294,11 +8198,11 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding) "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg); ok(rsaPubKey->magic == 0x32415352, - "Expected magic 0x32415352, got 0x%x\n", rsaPubKey->magic); + "Expected magic 0x32415352, got 0x%lx\n", rsaPubKey->magic); ok(rsaPubKey->bitlen == bitlen, - "Expected bitlen %d, got %d\n", bitlen, rsaPubKey->bitlen); + "Expected bitlen %d, got %ld\n", bitlen, rsaPubKey->bitlen); ok(rsaPubKey->pubexp == 65537, - "Expected pubexp 65537, got %d\n", rsaPubKey->pubexp); + "Expected pubexp 65537, got %ld\n", rsaPubKey->pubexp); ok(!memcmp(modulus, rsaPrivKeyModulus, bitlen/8), "unexpected modulus\n"); @@ -8319,7 +8223,6 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding) } } -/* Free *pInfo with HeapFree */ static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo) { BOOL ret; @@ -8331,37 +8234,37 @@ static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo) */ ret = CryptExportPublicKeyInfoEx(0, 0, 0, NULL, 0, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); ret = CryptExportPublicKeyInfoEx(0, AT_SIGNATURE, 0, NULL, 0, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); ret = CryptExportPublicKeyInfoEx(0, 0, X509_ASN_ENCODING, NULL, 0, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); ret = CryptExportPublicKeyInfoEx(0, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, NULL, &size); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); /* Test with no key */ ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, NULL, &size); - ok(!ret && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08x\n", + ok(!ret && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key); - ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); + ok(ret, "CryptGenKey failed: %08lx\n", GetLastError()); if (ret) { ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, NULL, &size); - ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError()); - *pInfo = HeapAlloc(GetProcessHeap(), 0, size); + ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError()); + *pInfo = malloc(size); if (*pInfo) { ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL, 0, NULL, *pInfo, &size); - ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", + ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError()); if (ret) { @@ -8407,6 +8310,9 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info) { BOOL ret; HCRYPTKEY key; +#ifndef __REACTOS__ + BCRYPT_KEY_HANDLE key2; +#endif PCCERT_CONTEXT context; DWORD dwSize; ALG_ID ai; @@ -8420,26 +8326,26 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info) */ ret = CryptImportPublicKeyInfoEx(0, 0, info, 0, 0, NULL, &key); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptImportPublicKeyInfoEx(csp, 0, info, 0, 0, NULL, &key); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); ret = CryptImportPublicKeyInfoEx(0, X509_ASN_ENCODING, info, 0, 0, NULL, &key); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); /* Export key with standard algorithm (CALG_RSA_KEYX) */ ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, info, 0, 0, NULL, &key); - ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError()); + ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError()); dwSize = sizeof(ai); ret = CryptGetKeyParam(key, KP_ALGID, (LPVOID)&ai, &dwSize, 0); - ok(ret, "CryptGetKeyParam failed: %08x\n", GetLastError()); + ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError()); if(ret) { - ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %d\n",dwSize); + ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize); ok(ai == CALG_RSA_KEYX, "Default ALG_ID is %04x (expected CALG_RSA_KEYX)\n", ai); } @@ -8448,14 +8354,14 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info) /* Repeat with forced algorithm */ ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, info, CALG_RSA_SIGN, 0, NULL, &key); - ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError()); + ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError()); dwSize = sizeof(ai); ret = CryptGetKeyParam(key, KP_ALGID, (LPVOID)&ai, &dwSize, 0); - ok(ret, "CryptGetKeyParam failed: %08x\n", GetLastError()); + ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError()); if(ret) { - ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %d\n",dwSize); + ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize); ok(ai == CALG_RSA_SIGN, "ALG_ID is %04x (expected CALG_RSA_SIGN)\n", ai); } @@ -8464,7 +8370,7 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info) /* Test importing a public key from a certificate context */ context = CertCreateCertificateContext(X509_ASN_ENCODING, expiredCert, sizeof(expiredCert)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); if (context) { @@ -8474,8 +8380,16 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info) context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId); ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, &context->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key); - ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError()); + ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError()); CryptDestroyKey(key); + +#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptImportPublicKeyInfoEx2 + ret = CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING, + &context->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &key2); + ok(ret, "CryptImportPublicKeyInfoEx2 failed: %08lx\n", GetLastError()); + BCryptDestroyKey(key2); +#endif + CertFreeCertificateContext(context); } } @@ -8498,29 +8412,663 @@ static void testPortPublicKeyInfo(void) testExportPublicKey(csp, &info); testImportPublicKey(csp, info); - HeapFree(GetProcessHeap(), 0, info); + free(info); CryptReleaseContext(csp, 0); ret = CryptAcquireContextA(&csp, cspName, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret,"CryptAcquireContextA failed\n"); } +static void test_encodeOCSPRequestInfo(DWORD dwEncoding) +{ + static const BYTE expected[] = + {0x30, 0x68, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, 0x61, 0x6d, + 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4d, 0x30, 0x4b, 0x30, + 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, + 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98 ,0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, + 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, + 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, + 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08}; + static const BYTE expected2[] = + {0x30, 0x81, 0xb6, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, 0x61, + 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x81, 0x9a, 0x30, + 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, + 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, + 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, + 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, + 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08, 0x30, 0x4b, 0x30, 0x49, + 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, + 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, + 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, + 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, + 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08}; + static const BYTE expected3[] = + {0x30, 0x81, 0x9d, 0x30, 0x81, 0x9a, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, + 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, + 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, + 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, + 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, + 0x8f, 0x49, 0x08, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, + 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, + 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, + 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, + 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08}; + static const BYTE expected4[] = + {0x30, 0x6a, 0x30, 0x68, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, + 0x61, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4d, 0x30, + 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, + 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, + 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, + 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, + 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08}; + static const BYTE issuer_name[] = + {0xe4, 0xe3 ,0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, + 0x09, 0x8a, 0xab, 0xd8}; + static const BYTE issuer_key[] = + {0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, + 0x95, 0x76, 0xb9, 0xf4}; + static const BYTE serial[] = + {0x08, 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, 0xb1}; + OCSP_REQUEST_ENTRY entry[2]; + CERT_ALT_NAME_ENTRY name; + OCSP_REQUEST_INFO info; + OCSP_SIGNED_REQUEST_INFO info_signed; + DWORD size; + BYTE *buf, *buf2; + BOOL ret; + + memset(&entry, 0, sizeof(entry)); + entry[0].CertId.HashAlgorithm.pszObjId = (char *)szOID_OIWSEC_sha1; + entry[0].CertId.IssuerNameHash.cbData = sizeof(issuer_name); + entry[0].CertId.IssuerNameHash.pbData = (BYTE *)issuer_name; + entry[0].CertId.IssuerKeyHash.cbData = sizeof(issuer_key); + entry[0].CertId.IssuerKeyHash.pbData = (BYTE *)issuer_key; + entry[0].CertId.SerialNumber.cbData = sizeof(serial); + entry[0].CertId.SerialNumber.pbData = (BYTE *)serial; + + name.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; + name.pwszDNSName = (WCHAR *)L"*.cm.steampowered.com"; + + info.dwVersion = OCSP_REQUEST_V1; + info.pRequestorName = &name; + info.cRequestEntry = 1; + info.rgRequestEntry = entry; + info.cExtension = 0; + info.rgExtension = NULL; + + size = 0; + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(size == sizeof(expected), "got %lu\n", size); + ok(!memcmp(buf, expected, sizeof(expected)), "unexpected value\n"); + + /* wrapped in OCSP_SIGNED_REQUEST_INFO */ + info_signed.ToBeSigned.cbData = size; + info_signed.ToBeSigned.pbData = buf; + info_signed.pOptionalSignatureInfo = NULL; + size = 0; + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_SIGNED_REQUEST, &info_signed, CRYPT_ENCODE_ALLOC_FLAG, NULL, + &buf2, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(size == sizeof(expected4), "got %lu\n", size); + ok(!memcmp(buf2, expected4, sizeof(expected4)), "unexpected value\n"); + LocalFree(buf); + LocalFree(buf2); + + /* two entries */ + entry[1].CertId.HashAlgorithm.pszObjId = (char *)szOID_OIWSEC_sha1; + entry[1].CertId.IssuerNameHash.cbData = sizeof(issuer_name); + entry[1].CertId.IssuerNameHash.pbData = (BYTE *)issuer_name; + entry[1].CertId.IssuerKeyHash.cbData = sizeof(issuer_key); + entry[1].CertId.IssuerKeyHash.pbData = (BYTE *)issuer_key; + entry[1].CertId.SerialNumber.cbData = sizeof(serial); + entry[1].CertId.SerialNumber.pbData = (BYTE *)serial; + info.cRequestEntry = 2; + + size = 0; + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(size == sizeof(expected2), "got %lu\n", size); + ok(!memcmp(buf, expected2, sizeof(expected2)), "unexpected value\n"); + LocalFree(buf); + + /* requestor name not set */ + info.pRequestorName = NULL; + size = 0; + SetLastError(0xdeadbeef); + ret = CryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(size == sizeof(expected3), "got %lu\n", size); + ok(!memcmp(buf, expected3, sizeof(expected3)), "unexpected value\n"); + LocalFree(buf); +} + +static const BYTE ocsp_response[] = { + 0x30, 0x03, 0x0a, 0x01, 0x06 +}; + +static const BYTE ocsp_response2[] = { + 0x30, 0x82, 0x01, 0xd3, 0x0a, 0x01, 0x00, 0xa0, 0x82, 0x01, 0xcc, 0x30, + 0x82, 0x01, 0xc8, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, + 0x01, 0x01, 0x04, 0x82, 0x01, 0xb9, 0x30, 0x82, 0x01, 0xb5, 0x30, 0x81, + 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, + 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, + 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x30, 0x37, 0x31, + 0x38, 0x33, 0x36, 0x34, 0x33, 0x5a, 0x30, 0x73, 0x30, 0x71, 0x30, 0x49, + 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, + 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, + 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, + 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, + 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0x08, 0x49, 0x8f, + 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, + 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x30, + 0x37, 0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f, + 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x34, 0x31, 0x37, 0x33, 0x36, + 0x30, 0x31, 0x5a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, + 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x2a, + 0xf3, 0x5f, 0xf7, 0x72, 0x6b, 0x27, 0x38, 0x6b, 0xae, 0x66, 0x42, 0xe0, + 0x3b, 0xc6, 0x44, 0x5f, 0x95, 0xe2, 0x1f, 0xbc, 0x3f, 0xb3, 0x1d, 0x6c, + 0x6c, 0x7c, 0x91, 0xb3, 0x02, 0x23, 0x0f, 0xf0, 0x13, 0x5f, 0x62, 0x92, + 0x0d, 0x91, 0xa9, 0x8f, 0x66, 0xe9, 0x18, 0xe3, 0xb1, 0xe0, 0x4c, 0x63, + 0x40, 0x9e, 0x14, 0x26, 0x28, 0x7a, 0x5e, 0x51, 0x99, 0x43, 0x1c, 0xd5, + 0xbd, 0x84, 0x88, 0x68, 0xd9, 0x0e, 0xd9, 0xf4, 0x78, 0x48, 0x9f, 0x01, + 0x4c, 0x34, 0x14, 0x1e, 0x7c, 0x72, 0x9c, 0xdd, 0x94, 0xcb, 0x6e, 0x28, + 0xf5, 0x76, 0x75, 0xa2, 0xbe, 0x4b, 0x52, 0xac, 0x38, 0x9d, 0xce, 0x52, + 0x68, 0x33, 0xbc, 0x52, 0xc7, 0xdc, 0x2f, 0x19, 0xff, 0x15, 0x9c, 0x4b, + 0xdb, 0x83, 0x4e, 0xd7, 0xf6, 0x9b, 0x7f, 0x76, 0x58, 0xa5, 0x46, 0x49, + 0xe3, 0x2d, 0x41, 0x26, 0xf8, 0xce, 0xb7, 0x56, 0x61, 0xb2, 0x88, 0x65, + 0x2b, 0xb8, 0x4d, 0xf2, 0xf2, 0x32, 0x50, 0x53, 0x8b, 0x0d, 0xc6, 0x58, + 0xac, 0xd8, 0xe4, 0x8d, 0x38, 0x9e, 0x61, 0xeb, 0x6b, 0xd2, 0xd6, 0x50, + 0x8d, 0xfa, 0x93, 0x47, 0x4e, 0x6e, 0x2b, 0xd3, 0xb9, 0xdc, 0xb9, 0xb5, + 0x86, 0x46, 0xcb, 0xda, 0xd9, 0xd8, 0xd5, 0x99, 0x7a, 0x7c, 0x73, 0xee, + 0xc1, 0x52, 0x8e, 0xc5, 0xca, 0x28, 0x1d, 0x15, 0x94, 0x06, 0xa0, 0xa5, + 0x01, 0xf3, 0xbd, 0x67, 0x3f, 0x3d, 0x46, 0x63, 0xc5, 0xba, 0xd5, 0x12, + 0xde, 0xb4, 0xc5, 0x86, 0xfe, 0x97, 0x6b, 0x70, 0xfe, 0xa4, 0x6a, 0x25, + 0x63, 0x8e, 0xcf, 0xa4, 0x13, 0x1c, 0x2b, 0xf7, 0xf4, 0xc9, 0x79, 0x8e, + 0x07, 0xa3, 0x25, 0x9f, 0xcf, 0x33, 0x65, 0x49, 0x84, 0xad, 0x7f, 0x90, + 0x44, 0x85, 0xd8, 0xa7, 0x73, 0x53, 0x56, 0x73, 0xca, 0x15, 0x39, 0x99, + 0x5f, 0x39, 0xfd +}; + +static void test_decodeOCSPResponseInfo(DWORD dwEncoding) +{ + OCSP_RESPONSE_INFO *info; + DWORD size; + BOOL ret; + + ret = CryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response, sizeof(ocsp_response), + CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(info->dwStatus == OCSP_UNAUTHORIZED_RESPONSE, "got %lu\n", info->dwStatus); + ok(info->pszObjId == NULL, "got %s\n", wine_dbgstr_a(info->pszObjId)); + ok(!info->Value.cbData, "got %lu\n", info->Value.cbData); + ok(info->Value.pbData == NULL, "got %p\n", info->Value.pbData); + LocalFree(info); + + ret = CryptDecodeObjectEx(dwEncoding, OCSP_RESPONSE, ocsp_response2, sizeof(ocsp_response2), + CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + ok(info->dwStatus == OCSP_SUCCESSFUL_RESPONSE, "got %lu\n", info->dwStatus); + ok(!strcmp(info->pszObjId, szOID_PKIX_OCSP_BASIC_SIGNED_RESPONSE), "got %s\n", wine_dbgstr_a(info->pszObjId)); + ok(info->Value.cbData == 441, "got %lu\n", info->Value.cbData); + ok(info->Value.pbData != NULL, "got %p\n", info->Value.pbData); + LocalFree(info); +} + +static const BYTE ocsp_basic_signed_response[] = { + 0x30, 0x82, 0x01, 0xb5, 0x30, 0x81, 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7, + 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, + 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32, + 0x32, 0x30, 0x33, 0x31, 0x30, 0x31, 0x38, 0x33, 0x36, 0x34, 0x38, 0x5a, + 0x30, 0x73, 0x30, 0x71, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, + 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, + 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, + 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, + 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, + 0xf4, 0x02, 0x10, 0x08, 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, + 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32, + 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x30, 0x31, 0x38, 0x32, 0x31, 0x30, + 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, + 0x31, 0x37, 0x31, 0x37, 0x33, 0x36, 0x30, 0x31, 0x5a, 0x30, 0x0d, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, + 0x03, 0x82, 0x01, 0x01, 0x00, 0x6a, 0x4c, 0xfa, 0xe6, 0xe3, 0x48, 0xbb, + 0xd6, 0x18, 0x33, 0x04, 0x9d, 0x6a, 0x92, 0x4d, 0x01, 0x74, 0x4f, 0x1a, + 0x70, 0xfa, 0xf2, 0x8b, 0xba, 0x0d, 0x2c, 0x06, 0x30, 0xc9, 0x55, 0xce, + 0x95, 0x13, 0x4d, 0x4c, 0x65, 0x99, 0xe7, 0xd6, 0x78, 0x9c, 0x3c, 0x9a, + 0x60, 0xeb, 0x43, 0x3c, 0x08, 0x1c, 0x02, 0x6d, 0x45, 0x2d, 0x5b, 0xdf, + 0xab, 0xf2, 0x92, 0xf1, 0x71, 0x61, 0xb4, 0x34, 0xcf, 0x84, 0x1f, 0xc9, + 0x3f, 0x45, 0x9e, 0x64, 0x89, 0x58, 0xdb, 0x2c, 0x73, 0xa8, 0x04, 0xae, + 0xad, 0xf2, 0xc5, 0x80, 0x80, 0xcf, 0x96, 0x4b, 0xf1, 0xb4, 0xf1, 0x2a, + 0x86, 0x1c, 0x7f, 0x1d, 0xcc, 0xbf, 0xd6, 0xa2, 0x3f, 0x44, 0xb8, 0x62, + 0x5b, 0x9b, 0x55, 0xc1, 0x4e, 0x18, 0x67, 0x5a, 0xbe, 0x31, 0xf5, 0x16, + 0x6d, 0x74, 0xc4, 0xf2, 0x60, 0x4f, 0xa1, 0x63, 0x49, 0xe9, 0xff, 0x37, + 0x3d, 0x66, 0xcd, 0xc3, 0x79, 0x4e, 0x38, 0x68, 0x1b, 0xbf, 0x0b, 0x3b, + 0xdb, 0xa0, 0x13, 0x70, 0xb8, 0xd1, 0x59, 0xe2, 0x8e, 0x88, 0xfe, 0x77, + 0x39, 0xa8, 0x3f, 0x93, 0xe1, 0xc6, 0x5e, 0x13, 0x9e, 0xea, 0xec, 0x49, + 0x65, 0x0b, 0x6d, 0xbf, 0x76, 0xd5, 0x11, 0x59, 0x7b, 0xfe, 0xe6, 0xb2, + 0x58, 0xa8, 0xbd, 0xd0, 0xe6, 0x13, 0x26, 0x72, 0x83, 0x78, 0x90, 0x85, + 0x82, 0x86, 0x9f, 0x2e, 0x20, 0x64, 0x90, 0xc3, 0xd1, 0x37, 0x50, 0xac, + 0xde, 0x52, 0x8e, 0x83, 0x9f, 0x02, 0x7b, 0xff, 0xf1, 0xd4, 0xe5, 0x8b, + 0x77, 0x8d, 0xef, 0x61, 0xcb, 0x85, 0x4d, 0xa0, 0x2e, 0x05, 0x28, 0xc0, + 0x86, 0x78, 0x59, 0xa9, 0x94, 0xb3, 0x90, 0x6b, 0xf7, 0xff, 0xd3, 0x08, + 0x96, 0x7c, 0xbe, 0x22, 0xd8, 0xb6, 0x35, 0xce, 0x1e, 0xae, 0x70, 0x34, + 0x05, 0x51, 0x49, 0xac, 0x2f, 0xe8, 0x67, 0xcf, 0xa7 +}; + +static const BYTE ocsp_basic_response[] = { + 0x30, 0x81, 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, + 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, + 0x76, 0xb9, 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, + 0x30, 0x31, 0x38, 0x33, 0x36, 0x34, 0x38, 0x5a, 0x30, 0x73, 0x30, 0x71, + 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, + 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, + 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, + 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, + 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0x08, + 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54, + 0x87, 0xc1, 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, + 0x33, 0x31, 0x30, 0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5a, 0xa0, 0x11, + 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x37, 0x31, 0x37, + 0x33, 0x36, 0x30, 0x31, 0x5a +}; + +static const BYTE ocsp_basic_response2[] = { + 0x30, 0x81, 0xbe, 0xa1, 0x34, 0x30, 0x32, 0x31, 0x0b, 0x30, 0x09, 0x06, + 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x16, 0x30, 0x14, + 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0d, 0x4c, 0x65, 0x74, 0x27, 0x73, + 0x20, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x02, 0x52, 0x33, 0x18, 0x0f, 0x32, + 0x30, 0x32, 0x32, 0x31, 0x30, 0x32, 0x30, 0x30, 0x36, 0x30, 0x31, 0x30, + 0x30, 0x5a, 0x30, 0x75, 0x30, 0x73, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x05, + 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x48, 0xda, 0xc9, + 0xa0, 0xfb, 0x2b, 0xd3, 0x2d, 0x4f, 0xf0, 0xde, 0x68, 0xd2, 0xf5, 0x67, + 0xb7, 0x35, 0xf9, 0xb3, 0xc4, 0x04, 0x14, 0x14, 0x2e, 0xb3, 0x17, 0xb7, + 0x58, 0x56, 0xcb, 0xae, 0x50, 0x09, 0x40, 0xe6, 0x1f, 0xaf, 0x9d, 0x8b, + 0x14, 0xc2, 0xc6, 0x02, 0x12, 0x03, 0x26, 0x1c, 0x82, 0x80, 0xf3, 0x8c, + 0x13, 0xef, 0xae, 0x83, 0x9d, 0x89, 0xb9, 0xcd, 0x59, 0x83, 0x5b, 0x80, + 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x31, 0x30, 0x32, 0x30, 0x30, + 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30, + 0x32, 0x32, 0x31, 0x30, 0x32, 0x37, 0x30, 0x35, 0x35, 0x39, 0x35, 0x38, + 0x5a +}; + +static const BYTE ocsp_basic_response_revoked[] = { + 0x30, 0x81, 0xb1, 0xa2, 0x16, 0x04, 0x14, 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, + 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, 0xdc, + 0xf5, 0x31, 0x7f, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, + 0x31, 0x30, 0x31, 0x32, 0x35, 0x30, 0x35, 0x5a, 0x30, 0x81, 0x85, 0x30, + 0x81, 0x82, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, + 0x1a, 0x05, 0x00, 0x04, 0x14, 0x74, 0xb4, 0xe7, 0x23, 0x19, 0xc7, 0x65, + 0x92, 0x15, 0x40, 0x44, 0x7b, 0xc7, 0xce, 0x3e, 0x90, 0xc2, 0x18, 0x76, + 0xeb, 0x04, 0x14, 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23, + 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, 0xdc, 0xf5, 0x31, 0x7f, 0x02, + 0x10, 0x0d, 0x2e, 0x67, 0xa2, 0x98, 0x85, 0x3b, 0x9a, 0x54, 0x52, 0xe3, + 0xa2, 0x85, 0xa4, 0x57, 0x2f, 0xa1, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32, + 0x31, 0x31, 0x30, 0x32, 0x37, 0x32, 0x31, 0x33, 0x38, 0x34, 0x38, 0x5a, + 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x31, 0x30, 0x31, + 0x30, 0x39, 0x30, 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32, + 0x32, 0x30, 0x34, 0x30, 0x37, 0x30, 0x30, 0x32, 0x34, 0x30, 0x31, 0x5a +}; + +static const BYTE ocsp_signature[] = { + 0x6a, 0x4c, 0xfa, 0xe6, 0xe3, 0x48, 0xbb, 0xd6, 0x18, 0x33, 0x04, 0x9d, + 0x6a, 0x92, 0x4d, 0x01, 0x74, 0x4f, 0x1a, 0x70, 0xfa, 0xf2, 0x8b, 0xba, + 0x0d, 0x2c, 0x06, 0x30, 0xc9, 0x55, 0xce, 0x95, 0x13, 0x4d, 0x4c, 0x65, + 0x99, 0xe7, 0xd6, 0x78, 0x9c, 0x3c, 0x9a, 0x60, 0xeb, 0x43, 0x3c, 0x08, + 0x1c, 0x02, 0x6d, 0x45, 0x2d, 0x5b, 0xdf, 0xab, 0xf2, 0x92, 0xf1, 0x71, + 0x61, 0xb4, 0x34, 0xcf, 0x84, 0x1f, 0xc9, 0x3f, 0x45, 0x9e, 0x64, 0x89, + 0x58, 0xdb, 0x2c, 0x73, 0xa8, 0x04, 0xae, 0xad, 0xf2, 0xc5, 0x80, 0x80, + 0xcf, 0x96, 0x4b, 0xf1, 0xb4, 0xf1, 0x2a, 0x86, 0x1c, 0x7f, 0x1d, 0xcc, + 0xbf, 0xd6, 0xa2, 0x3f, 0x44, 0xb8, 0x62, 0x5b, 0x9b, 0x55, 0xc1, 0x4e, + 0x18, 0x67, 0x5a, 0xbe, 0x31, 0xf5, 0x16, 0x6d, 0x74, 0xc4, 0xf2, 0x60, + 0x4f, 0xa1, 0x63, 0x49, 0xe9, 0xff, 0x37, 0x3d, 0x66, 0xcd, 0xc3, 0x79, + 0x4e, 0x38, 0x68, 0x1b, 0xbf, 0x0b, 0x3b, 0xdb, 0xa0, 0x13, 0x70, 0xb8, + 0xd1, 0x59, 0xe2, 0x8e, 0x88, 0xfe, 0x77, 0x39, 0xa8, 0x3f, 0x93, 0xe1, + 0xc6, 0x5e, 0x13, 0x9e, 0xea, 0xec, 0x49, 0x65, 0x0b, 0x6d, 0xbf, 0x76, + 0xd5, 0x11, 0x59, 0x7b, 0xfe, 0xe6, 0xb2, 0x58, 0xa8, 0xbd, 0xd0, 0xe6, + 0x13, 0x26, 0x72, 0x83, 0x78, 0x90, 0x85, 0x82, 0x86, 0x9f, 0x2e, 0x20, + 0x64, 0x90, 0xc3, 0xd1, 0x37, 0x50, 0xac, 0xde, 0x52, 0x8e, 0x83, 0x9f, + 0x02, 0x7b, 0xff, 0xf1, 0xd4, 0xe5, 0x8b, 0x77, 0x8d, 0xef, 0x61, 0xcb, + 0x85, 0x4d, 0xa0, 0x2e, 0x05, 0x28, 0xc0, 0x86, 0x78, 0x59, 0xa9, 0x94, + 0xb3, 0x90, 0x6b, 0xf7, 0xff, 0xd3, 0x08, 0x96, 0x7c, 0xbe, 0x22, 0xd8, + 0xb6, 0x35, 0xce, 0x1e, 0xae, 0x70, 0x34, 0x05, 0x51, 0x49, 0xac, 0x2f, + 0xe8, 0x67, 0xcf, 0xa7 +}; + +static const BYTE ocsp_basic_signed_response_with_cert[] = +{ + 0x30, 0x82, 0x05, 0x32, 0x30, 0x81, 0xdf, 0xa1, 0x54, 0x30, 0x52, 0x31, + 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58, + 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44, + 0x46, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, + 0x43, 0x57, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x04, 0x74, 0x65, 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65, + 0x73, 0x74, 0x40, 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x18, 0x0f, 0x32, + 0x30, 0x32, 0x34, 0x30, 0x34, 0x32, 0x35, 0x30, 0x30, 0x30, 0x36, 0x31, + 0x31, 0x5a, 0x30, 0x51, 0x30, 0x4f, 0x30, 0x3a, 0x30, 0x09, 0x06, 0x05, + 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x1b, 0xe8, 0x99, + 0x10, 0xe7, 0x3d, 0x9c, 0x6b, 0xba, 0x65, 0xb8, 0x6e, 0x6f, 0xd1, 0x63, + 0x52, 0xa5, 0x6f, 0xd9, 0x81, 0x04, 0x14, 0xc4, 0x57, 0x2a, 0x53, 0xb7, + 0x21, 0x6d, 0x03, 0x2d, 0xd0, 0xbc, 0xd4, 0x2a, 0x88, 0xd2, 0xae, 0x62, + 0xa9, 0x97, 0x2a, 0x02, 0x01, 0x02, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30, + 0x32, 0x34, 0x30, 0x34, 0x32, 0x35, 0x30, 0x30, 0x30, 0x36, 0x31, 0x31, + 0x5a, 0xa1, 0x23, 0x30, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2b, 0x06, 0x01, + 0x05, 0x05, 0x07, 0x30, 0x01, 0x02, 0x04, 0x12, 0x04, 0x10, 0xab, 0x7a, + 0x07, 0x8a, 0xef, 0xc9, 0x7e, 0xb3, 0x51, 0x90, 0xa5, 0x72, 0x09, 0x60, + 0x84, 0x27, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0xb5, 0x61, + 0x78, 0x5b, 0xc4, 0xb5, 0xe4, 0x8d, 0xff, 0xe1, 0xc5, 0x95, 0xd1, 0xad, + 0xb8, 0x55, 0xb4, 0xca, 0xcc, 0xf5, 0xe9, 0x6f, 0x63, 0x64, 0x4b, 0xf7, + 0x46, 0xf9, 0x12, 0x02, 0x36, 0xe1, 0x9f, 0xce, 0xe0, 0x5e, 0x6c, 0xf7, + 0x35, 0x19, 0x80, 0x89, 0x6b, 0x7d, 0x8f, 0xa1, 0x8c, 0xb1, 0x7d, 0xdc, + 0xf1, 0x1c, 0xf7, 0x70, 0x45, 0x77, 0xf3, 0xb4, 0x42, 0x99, 0x58, 0x68, + 0x11, 0xec, 0x41, 0x47, 0x11, 0xcc, 0xb1, 0x2f, 0xbb, 0x11, 0xe7, 0x81, + 0x7d, 0x17, 0x93, 0x30, 0xab, 0x58, 0xb1, 0xe0, 0x69, 0x34, 0x17, 0x3a, + 0xa0, 0x4a, 0xed, 0xd6, 0x9e, 0x02, 0xfd, 0xb7, 0xd1, 0x77, 0x3c, 0x59, + 0x47, 0xeb, 0xce, 0xa0, 0x64, 0x06, 0x38, 0x78, 0x96, 0x86, 0x77, 0x1e, + 0x3f, 0xa8, 0x56, 0x9d, 0xc4, 0x8f, 0x1d, 0x23, 0x23, 0x1c, 0xe6, 0x03, + 0x2c, 0xb9, 0xfd, 0xac, 0x3e, 0x30, 0x52, 0x51, 0x27, 0x35, 0x20, 0x93, + 0x94, 0xaa, 0x69, 0x83, 0xeb, 0x04, 0x32, 0x2a, 0xc0, 0x6b, 0x24, 0x30, + 0x6f, 0x0f, 0x61, 0xdb, 0xac, 0x01, 0x46, 0x71, 0x52, 0x96, 0x07, 0x48, + 0xba, 0xdf, 0x71, 0x96, 0x25, 0xa6, 0x04, 0x36, 0x49, 0xb9, 0xd9, 0x93, + 0x9a, 0x79, 0xbf, 0xad, 0x4a, 0x4f, 0x49, 0x98, 0x7d, 0xa3, 0x49, 0x1d, + 0x65, 0xb8, 0x51, 0x93, 0x60, 0x63, 0x91, 0x34, 0x5c, 0xe4, 0xad, 0x91, + 0x44, 0xc7, 0x69, 0x93, 0x82, 0x28, 0xce, 0xc1, 0xf6, 0xc2, 0xfb, 0xf5, + 0xef, 0xaf, 0xdb, 0xc2, 0x14, 0xed, 0x26, 0xad, 0xc9, 0xba, 0xee, 0xe8, + 0x40, 0xc6, 0x03, 0x21, 0x9a, 0x7a, 0x47, 0x45, 0x24, 0x5b, 0xc6, 0xf3, + 0xb4, 0x55, 0x7e, 0xa5, 0x86, 0x22, 0x60, 0x16, 0x4a, 0x67, 0x0b, 0xbd, + 0x92, 0x7a, 0x53, 0x6b, 0xa0, 0x05, 0x2e, 0x3c, 0xfa, 0x5e, 0x06, 0x4f, + 0xf1, 0x70, 0xa0, 0x82, 0x03, 0x38, 0x30, 0x82, 0x03, 0x34, 0x30, 0x82, + 0x03, 0x30, 0x30, 0x82, 0x02, 0x99, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x03, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x61, 0x31, 0x0b, 0x30, 0x09, 0x06, + 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44, 0x46, 0x31, 0x0d, 0x30, + 0x0b, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x04, 0x43, 0x44, 0x4d, 0x58, + 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x43, + 0x57, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, + 0x74, 0x65, 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65, 0x73, + 0x74, 0x40, 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x20, 0x17, 0x0d, + 0x32, 0x34, 0x30, 0x34, 0x32, 0x34, 0x32, 0x33, 0x35, 0x31, 0x31, 0x39, + 0x5a, 0x18, 0x0f, 0x32, 0x30, 0x35, 0x31, 0x30, 0x39, 0x30, 0x39, 0x32, + 0x33, 0x35, 0x31, 0x31, 0x39, 0x5a, 0x30, 0x52, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58, 0x31, 0x0b, 0x30, + 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44, 0x46, 0x31, 0x0b, + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x43, 0x57, 0x31, + 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65, + 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65, 0x73, 0x74, 0x40, + 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, + 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, + 0x01, 0x01, 0x00, 0xd5, 0x4d, 0x96, 0x69, 0x63, 0x59, 0x0a, 0x6e, 0x79, + 0x9e, 0x5a, 0x16, 0x0a, 0xb2, 0xc1, 0x2f, 0x9c, 0x73, 0x9f, 0x0d, 0x61, + 0xac, 0x48, 0x31, 0x04, 0x9f, 0xcb, 0x30, 0xb6, 0x47, 0xf3, 0xe3, 0x9d, + 0x9e, 0x96, 0xe6, 0xad, 0x2e, 0xe7, 0x40, 0x9e, 0x54, 0xe1, 0x85, 0x94, + 0x2f, 0xf5, 0xc4, 0x46, 0x21, 0x37, 0x57, 0xbe, 0x4f, 0x47, 0xda, 0x91, + 0x0b, 0xd6, 0x51, 0xe0, 0x13, 0x1c, 0x4b, 0x3f, 0xe8, 0xf2, 0xad, 0x8b, + 0xdb, 0xc1, 0x3d, 0xb5, 0x6c, 0x4d, 0xf7, 0x52, 0x5e, 0x67, 0x90, 0xd7, + 0xc8, 0xe9, 0xf5, 0x0a, 0xc1, 0x26, 0xbc, 0x00, 0x21, 0xca, 0xc1, 0xd5, + 0x37, 0xc2, 0xea, 0xd7, 0x82, 0x18, 0x94, 0x3e, 0xd7, 0x1a, 0x9e, 0xa6, + 0x77, 0x76, 0x37, 0xe8, 0x90, 0xeb, 0x4d, 0x09, 0x18, 0x6f, 0xda, 0xca, + 0x73, 0xbc, 0x15, 0x1f, 0xac, 0x14, 0x1f, 0xe5, 0x28, 0x3e, 0x04, 0x11, + 0x91, 0x71, 0x34, 0x50, 0xc4, 0xfc, 0x32, 0xb3, 0x2d, 0x0a, 0x9d, 0xa7, + 0x15, 0xca, 0x7a, 0xf8, 0x57, 0xc0, 0xe6, 0x92, 0x5e, 0x55, 0xa7, 0x45, + 0x58, 0x2b, 0xbf, 0x82, 0x23, 0x8d, 0xe4, 0xb7, 0x4a, 0xd4, 0x15, 0x44, + 0x80, 0x88, 0x16, 0x10, 0xcd, 0x42, 0x98, 0x46, 0xd1, 0x55, 0xa4, 0xa2, + 0xd8, 0xd8, 0x65, 0x33, 0x4d, 0x21, 0x6d, 0x1d, 0x11, 0x66, 0xd8, 0xa9, + 0xf9, 0x12, 0x42, 0x38, 0x2d, 0x36, 0x43, 0xa5, 0xe2, 0x5e, 0xff, 0x7c, + 0xae, 0xaa, 0xc8, 0x85, 0x42, 0xf3, 0xa0, 0x90, 0xd2, 0x04, 0xc9, 0xe4, + 0xa0, 0x0d, 0x97, 0xbb, 0x66, 0x8d, 0x81, 0xaa, 0x86, 0xa9, 0x49, 0x4c, + 0x14, 0x67, 0x02, 0xf6, 0x32, 0xde, 0x19, 0xf9, 0x14, 0xd0, 0xdb, 0x89, + 0xbf, 0x65, 0xc9, 0x87, 0x1d, 0xcc, 0xd3, 0x5f, 0x6a, 0xd4, 0x9d, 0x54, + 0x9d, 0x34, 0x08, 0xef, 0x7a, 0x77, 0x4f, 0x02, 0x03, 0x01, 0x00, 0x01, + 0xa3, 0x81, 0x80, 0x30, 0x7e, 0x30, 0x31, 0x06, 0x08, 0x2b, 0x06, 0x01, + 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, 0x25, 0x30, 0x23, 0x30, 0x21, 0x06, + 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x15, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, + 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x38, 0x30, 0x30, 0x09, 0x06, 0x03, + 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, + 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x58, 0x25, 0x0b, 0x7b, 0x6c, 0xe7, + 0x50, 0xdf, 0x45, 0x4b, 0x35, 0x37, 0xd1, 0x84, 0x25, 0x66, 0xbb, 0xda, + 0x7b, 0xc5, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, + 0x16, 0x80, 0x14, 0xc4, 0x57, 0x2a, 0x53, 0xb7, 0x21, 0x6d, 0x03, 0x2d, + 0xd0, 0xbc, 0xd4, 0x2a, 0x88, 0xd2, 0xae, 0x62, 0xa9, 0x97, 0x2a, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, + 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0xca, 0xbf, 0xb3, 0xcb, 0xf8, 0x5d, + 0x57, 0x25, 0xc4, 0xcd, 0xd3, 0xa2, 0xae, 0xcb, 0xc8, 0xe0, 0xd0, 0x16, + 0xa5, 0x54, 0x80, 0xf9, 0x6c, 0xa9, 0x4a, 0x8d, 0xa0, 0xea, 0x21, 0x6b, + 0xec, 0xfe, 0xa1, 0xdd, 0x48, 0x4c, 0xc0, 0x37, 0x5c, 0x36, 0x9f, 0x6d, + 0x3d, 0x89, 0x31, 0xc2, 0x74, 0xfd, 0xdf, 0x60, 0xa4, 0x05, 0xcb, 0x47, + 0xd2, 0x13, 0xa4, 0x23, 0x9f, 0xfb, 0x3c, 0x3f, 0x7a, 0x1f, 0x75, 0xfc, + 0x32, 0x8f, 0xbc, 0xb1, 0x3d, 0x7b, 0xef, 0x49, 0xd1, 0x47, 0x4a, 0x6d, + 0x6d, 0x8f, 0xd4, 0xb3, 0x71, 0x3d, 0x24, 0x48, 0x05, 0x1b, 0x29, 0xa7, + 0xe0, 0xbd, 0xad, 0x01, 0xff, 0x92, 0x2a, 0x24, 0x1e, 0x94, 0x6e, 0x59, + 0x7b, 0xd4, 0x98, 0xf0, 0x60, 0xe5, 0x69, 0xa2, 0x45, 0xaf, 0xd6, 0x7f, + 0x5b, 0x69, 0x84, 0x97, 0x23, 0xc7, 0xda, 0x3b, 0x37, 0xcd, 0x15, 0x4e, + 0x6b, 0xf0, +}; + +static void test_decodeOCSPBasicSignedResponseInfo(DWORD dwEncoding) +{ + OCSP_BASIC_SIGNED_RESPONSE_INFO *info; + DWORD size; + BOOL ret; + + size = 0; + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_SIGNED_RESPONSE, ocsp_basic_signed_response, + sizeof(ocsp_basic_signed_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + if (sizeof(void *) == 4) todo_wine ok(size == 496, "got %lu\n", size); + else ok(size == 536, "got %lu\n", size); + ok(info->ToBeSigned.cbData == sizeof(ocsp_basic_response), "got %lu\n", info->ToBeSigned.cbData); + ok(!memcmp(info->ToBeSigned.pbData, ocsp_basic_response, sizeof(ocsp_basic_response)), "wrong data\n"); + + ok(!strcmp(info->SignatureInfo.SignatureAlgorithm.pszObjId, szOID_RSA_SHA256RSA), + "got %s\n", info->SignatureInfo.SignatureAlgorithm.pszObjId); + ok(info->SignatureInfo.SignatureAlgorithm.Parameters.cbData == 2, + "got %lu\n", info->SignatureInfo.SignatureAlgorithm.Parameters.cbData); + ok(info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", + info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[0]); + ok(!info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[1], "got 0x%02x\n", + info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[1]); + + ok(info->SignatureInfo.Signature.cbData == sizeof(ocsp_signature), "got %lu\n", + info->SignatureInfo.Signature.cbData); + ok(!memcmp(info->SignatureInfo.Signature.pbData, ocsp_signature, sizeof(ocsp_signature)), + "wrong signature data\n"); + + ok(!info->SignatureInfo.cCertEncoded, "got %lu\n", info->SignatureInfo.cCertEncoded); + ok(!info->SignatureInfo.rgCertEncoded, "got %p\n", info->SignatureInfo.rgCertEncoded); + LocalFree(info); + + size = 0; + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_SIGNED_RESPONSE, ocsp_basic_signed_response_with_cert, + sizeof(ocsp_basic_signed_response_with_cert), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + LocalFree(info); +} + +static void test_decodeOCSPBasicResponseInfo(DWORD dwEncoding) +{ + static const BYTE resp_id[] = { + 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, + 0x95, 0x76, 0xb9, 0xf4}; + static const BYTE resp_id2[] = { + 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, + 0xdc, 0xf5, 0x31, 0x7f}; + static const BYTE resp_id3[] = { + 0x30, 0x32, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, + 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0d, 0x4c, 0x65, 0x74, 0x27, 0x73, 0x20, + 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x03, + 0x13, 0x02, 0x52, 0x33}; + static const BYTE name_hash[] = { + 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, + 0x09, 0x8a, 0xab, 0xd8}; + static const BYTE name_hash2[] = { + 0x74, 0xb4, 0xe7, 0x23, 0x19, 0xc7, 0x65, 0x92, 0x15, 0x40, 0x44, 0x7b, 0xc7, 0xce, 0x3e, 0x90, + 0xc2, 0x18, 0x76, 0xeb}; + static const BYTE name_hash3[] = { + 0x48, 0xda, 0xc9, 0xa0, 0xfb, 0x2b, 0xd3, 0x2d, 0x4f, 0xf0, 0xde, 0x68, 0xd2, 0xf5, 0x67, 0xb7, + 0x35, 0xf9, 0xb3, 0xc4}; + static const BYTE key_hash[] = { + 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, + 0x95, 0x76, 0xb9, 0xf4}; + static const BYTE key_hash2[] = { + 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, + 0xdc, 0xf5, 0x31, 0x7f}; + static const BYTE key_hash3[] = { + 0x14, 0x2e, 0xb3, 0x17, 0xb7, 0x58, 0x56, 0xcb, 0xae, 0x50, 0x09, 0x40, 0xe6, 0x1f, 0xaf, 0x9d, + 0x8b, 0x14, 0xc2, 0xc6}; + static const BYTE serial[] = { + 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08}; + static const BYTE serial2[] = { + 0x2f, 0x57, 0xa4, 0x85, 0xa2, 0xe3, 0x52, 0x54, 0x9a, 0x3b, 0x85, 0x98, 0xa2, 0x67, 0x2e, 0x0d}; + static const BYTE serial3[] = { + 0x5b, 0x83, 0x59, 0xcd, 0xb9, 0x89, 0x9d, 0x83, 0xae, 0xef, 0x13, 0x8c, 0xf3, 0x80, 0x82, 0x1c, + 0x26, 0x03}; + OCSP_BASIC_RESPONSE_INFO *info; + OCSP_BASIC_RESPONSE_ENTRY *entry; + OCSP_BASIC_REVOKED_INFO *revoked; + DWORD size; + BOOL ret; + + /* good cert */ + size = 0; + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response, + sizeof(ocsp_basic_response), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + + ok(!info->dwVersion, "got %lu\n", info->dwVersion); + ok(info->dwResponderIdChoice == 2, "got %lu\n", info->dwResponderIdChoice); + ok(info->ByKeyResponderId.cbData == sizeof(resp_id), "got %lu\n", info->ByKeyResponderId.cbData); + ok(!memcmp(info->ByKeyResponderId.pbData, resp_id, sizeof(resp_id)), "wrong data\n"); + ok(info->ProducedAt.dwLowDateTime == 3438583808, "got %lu\n", info->ProducedAt.dwLowDateTime); + ok(info->ProducedAt.dwHighDateTime == 30946477, "got %lu\n", info->ProducedAt.dwHighDateTime); + ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry); + ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry); + + entry = info->rgResponseEntry; + ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId); + ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData); + ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]); + ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]); + ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash), "got %lu\n", entry->CertId.IssuerNameHash.cbData); + ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash, sizeof(name_hash)), "wrong data\n"); + ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash), "got %lu\n", entry->CertId.IssuerKeyHash.cbData); + ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash, sizeof(key_hash)), "wrong data\n"); + ok(entry->CertId.SerialNumber.cbData == sizeof(serial), "got %lu\n", entry->CertId.SerialNumber.cbData); + ok(!memcmp(entry->CertId.SerialNumber.pbData, serial, sizeof(serial)), "wrong data\n"); + ok(entry->dwCertStatus == 0, "got %lu\n", entry->dwCertStatus); + ok(entry->pRevokedInfo == NULL, "got %p\n", entry->pRevokedInfo); + ok(entry->ThisUpdate.dwLowDateTime == 2558518400, "got %lu\n", entry->ThisUpdate.dwLowDateTime); + ok(entry->ThisUpdate.dwHighDateTime == 30946475, "got %lu\n", entry->ThisUpdate.dwHighDateTime); + ok(entry->NextUpdate.dwLowDateTime == 2014369408, "got %lu\n", entry->NextUpdate.dwLowDateTime); + ok(entry->NextUpdate.dwHighDateTime == 30947877, "got %lu\n", entry->NextUpdate.dwHighDateTime); + ok(!entry->cExtension, "got %lu\n", entry->cExtension); + ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension); + + ok(!info->cExtension, "got %lu\n", info->cExtension); + ok(info->rgExtension == NULL, "got %p\n", info->rgExtension); + LocalFree(info); + + /* revoked cert */ + size = 0; + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response_revoked, + sizeof(ocsp_basic_response_revoked), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + + ok(!info->dwVersion, "got %lu\n", info->dwVersion); + ok(info->dwResponderIdChoice == 2, "got %lu\n", info->dwResponderIdChoice); + ok(info->ByKeyResponderId.cbData == sizeof(resp_id), "got %lu\n", info->ByKeyResponderId.cbData); + ok(!memcmp(info->ByKeyResponderId.pbData, resp_id2, sizeof(resp_id2)), "wrong data\n"); + ok(info->ProducedAt.dwLowDateTime == 647048832, "got %lu\n", info->ProducedAt.dwLowDateTime); + ok(info->ProducedAt.dwHighDateTime == 30950558, "got %lu\n", info->ProducedAt.dwHighDateTime); + ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry); + ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry); + + entry = info->rgResponseEntry; + ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId); + ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData); + ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]); + ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]); + ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash2), "got %lu\n", entry->CertId.IssuerNameHash.cbData); + ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash2, sizeof(name_hash2)), "wrong data\n"); + ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash2), "got %lu\n", entry->CertId.IssuerKeyHash.cbData); + ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash2, sizeof(key_hash2)), "wrong data\n"); + ok(entry->CertId.SerialNumber.cbData == sizeof(serial2), "got %lu\n", entry->CertId.SerialNumber.cbData); + ok(!memcmp(entry->CertId.SerialNumber.pbData, serial2, sizeof(serial2)), "wrong data\n"); + ok(entry->dwCertStatus == 1, "got %lu\n", entry->dwCertStatus); + ok(entry->pRevokedInfo != NULL, "got NULL\n"); + + revoked = entry->pRevokedInfo; + ok(revoked->RevocationDate.dwLowDateTime == 107865088, "got %lu\n", revoked->RevocationDate.dwLowDateTime); + ok(revoked->RevocationDate.dwHighDateTime == 30919547, "got %lu\n", revoked->RevocationDate.dwHighDateTime); + ok(!revoked->dwCrlReasonCode, "got %lu\n", revoked->dwCrlReasonCode); + + ok(entry->ThisUpdate.dwLowDateTime == 3891950720, "got %lu\n", entry->ThisUpdate.dwLowDateTime); + ok(entry->ThisUpdate.dwHighDateTime == 30950555, "got %lu\n", entry->ThisUpdate.dwHighDateTime); + ok(entry->NextUpdate.dwLowDateTime == 3347801728, "got %lu\n", entry->NextUpdate.dwLowDateTime); + ok(entry->NextUpdate.dwHighDateTime == 30951957, "got %lu\n", entry->NextUpdate.dwHighDateTime); + ok(!entry->cExtension, "got %lu\n", entry->cExtension); + ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension); + + ok(!info->cExtension, "got %lu\n", info->cExtension); + ok(info->rgExtension == NULL, "got %p\n", info->rgExtension); + LocalFree(info); + + size = 0; + ret = CryptDecodeObjectEx(dwEncoding, OCSP_BASIC_RESPONSE, ocsp_basic_response2, + sizeof(ocsp_basic_response2), CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + ok(ret, "got %08lx\n", GetLastError()); + + ok(!info->dwVersion, "got %lu\n", info->dwVersion); + ok(info->dwResponderIdChoice == 1, "got %lu\n", info->dwResponderIdChoice); + ok(info->ByNameResponderId.cbData == sizeof(resp_id3), "got %lu\n", info->ByNameResponderId.cbData); + ok(!memcmp(info->ByNameResponderId.pbData, resp_id3, sizeof(resp_id3)), "wrong data\n"); + + ok(info->ProducedAt.dwLowDateTime == 1408824832, "got %lu\n", info->ProducedAt.dwLowDateTime); + ok(info->ProducedAt.dwHighDateTime == 30991433, "got %lu\n", info->ProducedAt.dwHighDateTime); + ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry); + ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry); + + entry = info->rgResponseEntry; + ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId); + ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData); + ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]); + ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]); + ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash3), "got %lu\n", entry->CertId.IssuerNameHash.cbData); + ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash3, sizeof(name_hash3)), "wrong data\n"); + + ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash3), "got %lu\n", entry->CertId.IssuerKeyHash.cbData); + ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash3, sizeof(key_hash3)), "wrong data\n"); + ok(entry->CertId.SerialNumber.cbData == sizeof(serial3), "got %lu\n", entry->CertId.SerialNumber.cbData); + ok(!memcmp(entry->CertId.SerialNumber.pbData, serial3, sizeof(serial3)), "wrong data\n"); + ok(entry->dwCertStatus == 0, "got %lu\n", entry->dwCertStatus); + ok(entry->pRevokedInfo == NULL, "got %p\n", entry->pRevokedInfo); + ok(entry->ThisUpdate.dwLowDateTime == 808824832, "got %lu\n", entry->ThisUpdate.dwLowDateTime); + ok(entry->ThisUpdate.dwHighDateTime == 30991433, "got %lu\n", entry->ThisUpdate.dwHighDateTime); + ok(entry->NextUpdate.dwLowDateTime == 1474872064, "got %lu\n", entry->NextUpdate.dwLowDateTime); + ok(entry->NextUpdate.dwHighDateTime == 30992841, "got %lu\n", entry->NextUpdate.dwHighDateTime); + ok(!entry->cExtension, "got %lu\n", entry->cExtension); + ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension); + + ok(!info->cExtension, "got %lu\n", info->cExtension); + ok(info->rgExtension == NULL, "got %p\n", info->rgExtension); + LocalFree(info); +} + START_TEST(encode) { static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING }; - HMODULE hCrypt32; DWORD i; - hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptDecodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptDecodeObjectEx"); - pCryptEncodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptEncodeObjectEx"); - if (!pCryptDecodeObjectEx || !pCryptEncodeObjectEx) - { - win_skip("CryptDecodeObjectEx() is not available\n"); - return; - } - for (i = 0; i < ARRAY_SIZE(encodings); i++) { test_encodeInt(encodings[i]); @@ -8547,6 +9095,8 @@ START_TEST(encode) test_decodeBasicConstraints(encodings[i]); test_encodeRsaPublicKey(encodings[i]); test_decodeRsaPublicKey(encodings[i]); + test_encodeRsaPublicKey_Bcrypt(encodings[i]); + test_decodeRsaPublicKey_Bcrypt(encodings[i]); test_encodeSequenceOfAny(encodings[i]); test_decodeSequenceOfAny(encodings[i]); test_encodeExtensions(encodings[i]); @@ -8596,6 +9146,17 @@ START_TEST(encode) test_encodeCertPolicyConstraints(encodings[i]); test_decodeCertPolicyConstraints(encodings[i]); test_decodeRsaPrivateKey(encodings[i]); +#ifdef __REACTOS__ + if ((GetVersion() & 0xFF) > 5) // These tests crash on Server 2003 + { +#endif + test_encodeOCSPRequestInfo(encodings[i]); + test_decodeOCSPResponseInfo(encodings[i]); + test_decodeOCSPBasicSignedResponseInfo(encodings[i]); + test_decodeOCSPBasicResponseInfo(encodings[i]); +#ifdef __REACTOS__ + } +#endif } testPortPublicKeyInfo(); } diff --git a/modules/rostests/winetests/crypt32/main.c b/modules/rostests/winetests/crypt32/main.c index 6a031527d81..19dde3fb28f 100644 --- a/modules/rostests/winetests/crypt32/main.c +++ b/modules/rostests/winetests/crypt32/main.c @@ -42,7 +42,7 @@ static void test_findAttribute(void) SetLastError(0xdeadbeef); ret = CertFindAttribute(NULL, 0, NULL); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); if (0) { @@ -54,25 +54,25 @@ static void test_findAttribute(void) SetLastError(0xdeadbeef); ret = CertFindAttribute(NULL, 1, &attr); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(), + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), GetLastError()); } /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindAttribute("bogus", 1, &attr); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindAttribute("1.2.4", 1, &attr); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* succeeds, last error not set */ SetLastError(0xdeadbeef); ret = CertFindAttribute("1.2.3", 1, &attr); - ok(ret != NULL, "CertFindAttribute failed: %08x\n", GetLastError()); + ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError()); } static void test_findExtension(void) @@ -86,7 +86,7 @@ static void test_findExtension(void) SetLastError(0xdeadbeef); ret = CertFindExtension(NULL, 0, NULL); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); if (0) { @@ -99,25 +99,25 @@ static void test_findExtension(void) SetLastError(0xdeadbeef); ret = CertFindExtension(NULL, 1, &ext); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(), + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), GetLastError()); } /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindExtension("bogus", 1, &ext); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindExtension("1.2.4", 1, &ext); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* succeeds, last error not set */ SetLastError(0xdeadbeef); ret = CertFindExtension("1.2.3", 1, &ext); - ok(ret != NULL, "CertFindExtension failed: %08x\n", GetLastError()); + ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError()); } static void test_findRDNAttr(void) @@ -142,25 +142,25 @@ static void test_findRDNAttr(void) SetLastError(0xdeadbeef); ret = CertFindRDNAttr(NULL, &nameInfo); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(), + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), GetLastError()); } /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindRDNAttr("bogus", &nameInfo); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* returns NULL, last error not set */ SetLastError(0xdeadbeef); ret = CertFindRDNAttr("1.2.4", &nameInfo); ok(ret == NULL, "Expected failure\n"); - ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n", + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", GetLastError()); /* succeeds, last error not set */ SetLastError(0xdeadbeef); ret = CertFindRDNAttr("1.2.3", &nameInfo); - ok(ret != NULL, "CertFindRDNAttr failed: %08x\n", GetLastError()); + ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError()); } static void test_verifyTimeValidity(void) @@ -178,16 +178,16 @@ static void test_verifyTimeValidity(void) */ /* Check with 0 NotBefore and NotAfter */ ret = CertVerifyTimeValidity(&fileTime, &info); - ok(ret == 1, "Expected 1, got %d\n", ret); + ok(ret == 1, "Expected 1, got %ld\n", ret); info.NotAfter = fileTime; /* Check with NotAfter equal to comparison time */ ret = CertVerifyTimeValidity(&fileTime, &info); - ok(ret == 0, "Expected 0, got %d\n", ret); + ok(ret == 0, "Expected 0, got %ld\n", ret); /* Check with NotBefore after comparison time */ info.NotBefore = fileTime; info.NotBefore.dwLowDateTime += 5000; ret = CertVerifyTimeValidity(&fileTime, &info); - ok(ret == -1, "Expected -1, got %d\n", ret); + ok(ret == -1, "Expected -1, got %ld\n", ret); } static void test_cryptAllocate(void) @@ -195,12 +195,12 @@ static void test_cryptAllocate(void) LPVOID buf; buf = CryptMemAlloc(0); - ok(buf != NULL, "CryptMemAlloc failed: %08x\n", GetLastError()); + ok(buf != NULL, "CryptMemAlloc failed: %08lx\n", GetLastError()); CryptMemFree(buf); /* CryptMemRealloc(NULL, 0) fails pre-Vista */ buf = CryptMemAlloc(0); buf = CryptMemRealloc(buf, 1); - ok(buf != NULL, "CryptMemRealloc failed: %08x\n", GetLastError()); + ok(buf != NULL, "CryptMemRealloc failed: %08lx\n", GetLastError()); CryptMemFree(buf); } @@ -223,7 +223,7 @@ static void test_cryptTls(void) /* One normal pass */ index = pI_CryptAllocTls(); - ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError()); + ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError()); if (index) { LPVOID ptr; @@ -231,22 +231,22 @@ static void test_cryptTls(void) ptr = pI_CryptGetTls(index); ok(!ptr, "Expected NULL\n"); ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef); - ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError()); + ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError()); 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); - ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError()); + ok(ret, "I_CryptFreeTls failed: %08lx\n", GetLastError()); ret = pI_CryptFreeTls(index, 0); ok(!ret, "I_CryptFreeTls succeeded\n"); ok(GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } /* Similar pass, check I_CryptDetachTls */ index = pI_CryptAllocTls(); - ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError()); + ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError()); if (index) { LPVOID ptr; @@ -254,7 +254,7 @@ static void test_cryptTls(void) ptr = pI_CryptGetTls(index); ok(!ptr, "Expected NULL\n"); ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef); - ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError()); + ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError()); ptr = pI_CryptGetTls(index); ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr); ptr = pI_CryptDetachTls(index); @@ -272,34 +272,26 @@ static void test_readTrustedPublisherDWORD(void) pReadDWORD = (void *)GetProcAddress(hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry"); if (pReadDWORD) { - 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; DWORD size, readFlags = 0, returnedFlags; HKEY key; LONG rc; - rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, safer, &key); + rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, + L"Software\\Policies\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer", &key); if (rc == ERROR_SUCCESS) { size = sizeof(readFlags); - rc = RegQueryValueExW(key, authenticodeFlags, NULL, NULL, + rc = RegQueryValueExW(key, L"AuthenticodeFlags", NULL, NULL, (LPBYTE)&readFlags, &size); if (rc == ERROR_SUCCESS) exists = TRUE; } returnedFlags = 0xdeadbeef; - ret = pReadDWORD(authenticodeFlags, &returnedFlags); + ret = pReadDWORD(L"AuthenticodeFlags", &returnedFlags); ok(ret == exists, "Unexpected return value\n"); ok(readFlags == returnedFlags, - "Expected flags %08x, got %08x\n", readFlags, returnedFlags); + "Expected flags %08lx, got %08lx\n", readFlags, returnedFlags); } } @@ -337,28 +329,28 @@ static void test_getDefaultCryptProv(void) prov = pI_CryptGetDefaultCryptProv(0xdeadbeef); ok(prov == 0 && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL); ok(prov == 0 && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); prov = pI_CryptGetDefaultCryptProv(1); ok(prov == 0 && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); prov = pI_CryptGetDefaultCryptProv(0); - ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError()); + ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError()); CryptReleaseContext(prov, 0); for (i = 0; i < ARRAY_SIZE(test_prov); i++) { if (winetest_debug > 1) - trace("%u: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name, + trace("%lu: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name, GET_ALG_CLASS(test_prov[i].algid) >> 13, GET_ALG_TYPE(test_prov[i].algid) >> 9, GET_ALG_SID(test_prov[i].algid)); prov = pI_CryptGetDefaultCryptProv(test_prov[i].algid); if (!prov) { -todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_NO_SIGN) - ok(test_prov[i].optional, "%u: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid); + todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_NO_SIGN) + ok(test_prov[i].optional, "%lu: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid); continue; } @@ -367,9 +359,9 @@ todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_N { name = CryptMemAlloc(size); ret = CryptGetProvParam(prov, PP_NAME, (BYTE *)name, &size, 0); - ok(ret, "%u: CryptGetProvParam failed %#x\n", i, GetLastError()); + ok(ret, "%lu: CryptGetProvParam failed %#lx\n", i, GetLastError()); if (winetest_debug > 1) - trace("%u: algid %#x, name %s\n", i, test_prov[i].algid, name); + trace("%lu: algid %#x, name %s\n", i, test_prov[i].algid, name); CryptMemFree(name); } @@ -393,119 +385,92 @@ static void test_CryptInstallOssGlobal(void) } } -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 (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 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[] = L"02 1f 01 02 03 04 05 06 07 08 09 " + "0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f"; + BOOL ret; DWORD size; - LPWSTR str; + WCHAR str[100]; - pCryptFormatObject = (void *)GetProcAddress(hCrypt, "CryptFormatObject"); - if (!pCryptFormatObject) - { - skip("No CryptFormatObject\n"); - return; - } /* Crash */ if (0) { - pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL); + CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL); } /* 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()); + ret = CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size); + ok(!ret, "expected failure\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\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) - { - if (size == 0 && GetLastError() == ERROR_FILE_NOT_FOUND) - { - win_skip("CryptFormatObject has no default implementation\n"); - return; - } - 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()); - ok(!lstrcmpiW(str, encodedBigIntStr), "unexpected format string\n"); - HeapFree(GetProcessHeap(), 0, str); - } + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, NULL, &size); + ok(ret, "CryptFormatObject failed: %ld\n", GetLastError()); + ok(size == sizeof(WCHAR) || broken(!size) /* Win10 1709+ */, "wrong size %ld\n", size); + + SetLastError(0xdeadbeef); + size = 0; + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size); + ok(!ret, "expected failure\n"); + ok(GetLastError() == ERROR_MORE_DATA, "wrong error %lu\n", GetLastError()); + + size = sizeof(WCHAR); + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size); + ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError()); + ok(!str[0], "expected empty string\n"); + + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt, + sizeof(encodedInt), NULL, &size); + ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError()); + ok(size >= sizeof(L"02 01 01"), "wrong size %lu\n", size); + + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt, + sizeof(encodedInt), str, &size); + ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError()); + ok(!wcscmp(str, L"02 01 01"), "wrong string %s\n", wine_dbgstr_w(str)); + + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedBigInt, + sizeof(encodedBigInt), NULL, &size); + ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError()); + ok(size >= sizeof(encodedBigIntStr), "wrong size %lu\n", size); + + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, + encodedBigInt, sizeof(encodedBigInt), str, &size); + ok(ret, "CryptFormatObject failed: %ld\n", GetLastError()); + ok(!wcsicmp(str, encodedBigIntStr), "wrong string %s\n", wine_dbgstr_w(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); + ret = CryptFormatObject(X509_ASN_ENCODING, 0, CRYPT_FORMAT_STR_NO_HEX, + NULL, NULL, NULL, 0, NULL, &size); 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()); + ok(GetLastError() == ERROR_FILE_NOT_FOUND + || GetLastError() == 0xdeadbeef, /* Vista, W2K8 */ + "wrong error %lu\n", GetLastError()); + /* 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()); + ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, + szOID_AUTHORITY_KEY_IDENTIFIER2, NULL, 0, NULL, &size); + ok(!ret, "expected failure\n"); + ok(GetLastError() == E_INVALIDARG, "wrong error %lu\n", GetLastError()); } START_TEST(main) diff --git a/modules/rostests/winetests/crypt32/message.c b/modules/rostests/winetests/crypt32/message.c index 7e2e8aa8408..e6339553e52 100644 --- a/modules/rostests/winetests/crypt32/message.c +++ b/modules/rostests/winetests/crypt32/message.c @@ -27,23 +27,6 @@ #include "wine/test.h" -static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); - -static void init_function_pointers(void) -{ - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hAdvapi32, CryptAcquireContextA) - -#undef GET_PROC -} - static const BYTE dataEmptyBareContent[] = { 0x04,0x00 }; static const BYTE dataEmptyContent[] = { 0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x02, @@ -70,40 +53,35 @@ static void test_msg_get_signer_count(void) SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(0, NULL, 0); - ok(count == -1, "Expected -1, got %d\n", count); - ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", + ok(count == -1, "Expected -1, got %ld\n", count); + ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, NULL, 0); - ok(count == -1, "Expected -1, got %d\n", count); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win9x */ - "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(count == -1, "Expected -1, got %ld\n", count); + ok(GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, dataEmptyBareContent, sizeof(dataEmptyBareContent)); - ok(count == -1, "Expected -1, got %d\n", count); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH, /* win9x */ - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(count == -1, "Expected -1, got %ld\n", count); + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, dataEmptyContent, sizeof(dataEmptyContent)); - ok(count == -1, "Expected -1, got %d\n", count); + ok(count == -1, "Expected -1, got %ld\n", count); ok(GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, signedEmptyBareContent, sizeof(signedEmptyBareContent)); - ok(count == -1, "Expected -1, got %d\n", count); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR, /* win9x */ - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(count == -1, "Expected -1, got %ld\n", count); + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, signedEmptyContent, sizeof(signedEmptyContent)); - ok(count == 1 || - broken(count == -1), /* win9x */ - "Expected 1, got %d\n", count); + ok(count == 1, "Expected 1, got %ld\n", count); } static BYTE detachedHashContent[] = { @@ -132,46 +110,42 @@ static void test_verify_detached_message_hash(void) ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); para.dwMsgEncodingType = X509_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, NULL, 0, 0, NULL, NULL, NULL, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Curiously, passing no data to hash succeeds.. */ ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 0, NULL, NULL, NULL, NULL); todo_wine - ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError()); /* as does passing the actual content of the message to hash.. */ size = sizeof(msgData); pMsgData = msgData; ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL); - ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError()); /* while passing data to hash that isn't the content of the message fails. */ size = sizeof(detachedHashContent); @@ -180,7 +154,7 @@ static void test_verify_detached_message_hash(void) ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE, - "expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError()); + "expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError()); /* Getting the size of the hash while passing no hash data causes the * hash to be checked (and fail.) */ @@ -188,23 +162,23 @@ static void test_verify_detached_message_hash(void) ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 0, NULL, NULL, NULL, &hashSize); ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE, - "expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError()); + "expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError()); size = sizeof(msgData); pMsgData = msgData; ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, &hashSize); - ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError()); - ok(hashSize == sizeof(hash), "unexpected size %d\n", hashSize); + ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError()); + ok(hashSize == sizeof(hash), "unexpected size %ld\n", hashSize); hashSize = 1; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize); ok(!ret && GetLastError() == ERROR_MORE_DATA, - "expected ERROR_MORE_DATA, got %08x\n", GetLastError()); + "expected ERROR_MORE_DATA, got %08lx\n", GetLastError()); hashSize = sizeof(hash); ret = CryptVerifyDetachedMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize); - ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError()); } static BYTE hashContent[] = { @@ -228,31 +202,30 @@ static void test_verify_message_hash(void) SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win98 */ - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Verifying the hash of a detached message succeeds? */ ret = CryptVerifyMessageHash(¶, detachedHashContent, sizeof(detachedHashContent), NULL, NULL, NULL, NULL); todo_wine - ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError()); /* As does verifying the hash of a regular message. */ ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), NULL, NULL, NULL, NULL); - ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError()); ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), NULL, &size, NULL, NULL); - ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); + ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError()); if (ret) buf = CryptMemAlloc(size); if (buf) @@ -261,11 +234,11 @@ static void test_verify_message_hash(void) ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), buf, &size, NULL, NULL); ok(!ret && GetLastError() == ERROR_MORE_DATA, - "expected ERROR_MORE_DATA, got %08x\n", GetLastError()); + "expected ERROR_MORE_DATA, got %08lx\n", GetLastError()); ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), buf, &size, NULL, NULL); - ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); - ok(size == sizeof(msgData), "unexpected size %d\n", size); + ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError()); + ok(size == sizeof(msgData), "unexpected size %ld\n", size); ok(!memcmp(buf, msgData, size), "unexpected value\n"); CryptMemFree(buf); } @@ -355,32 +328,31 @@ static void test_verify_detached_message_signature(void) ret = CryptVerifyDetachedMessageSignature(NULL, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.dwMsgAndCertEncodingType = X509_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, NULL, 0, 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG, /* win98 */ - "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* None of these messages contains a cert in the message itself, so the * default callback isn't able to verify their signature. */ @@ -389,39 +361,33 @@ static void test_verify_detached_message_signature(void) sizeof(signedWithCertContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); todo_wine - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, signedContent, sizeof(signedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); pContent = msgData; cbContent = sizeof(msgData); ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Passing the correct callback results in success */ para.pfnGetSignerCertificate = msg_get_signer_callback; ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL); - ok(ret || - broken(!ret), /* win98 */ - "CryptVerifyDetachedMessageSignature failed: %08x\n", + ok(ret, "CryptVerifyDetachedMessageSignature failed: %08lx\n", GetLastError()); /* Not passing the correct data to be signed results in the signature not * matching. @@ -430,9 +396,8 @@ static void test_verify_detached_message_signature(void) ret = CryptVerifyDetachedMessageSignature(¶, 0, detachedSignedContent, sizeof(detachedSignedContent), 0, NULL, NULL, NULL); ok(!ret, "Expected 0, got %d\n", ret); - ok(GetLastError() == NTE_BAD_SIGNATURE || - GetLastError() == OSS_DATA_ERROR, /* win98 */ - "Expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(GetLastError() == NTE_BAD_SIGNATURE, + "Expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError()); } static const BYTE signedWithCertEmptyContent[] = { @@ -510,86 +475,74 @@ static void test_verify_message_signature(void) SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Is cbDecoded set when invalid parameters are passed? */ cbDecoded = 0xdeadbeef; ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, &cbDecoded, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ok(cbDecoded == 0, "expected 0, got %08x\n", cbDecoded); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); + ok(cbDecoded == 0, "expected 0, got %08lx\n", cbDecoded); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = 0; para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG), /* win9x */ - "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); /* Check whether cert is set on error */ cert = (PCCERT_CONTEXT)0xdeadbeef; ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, 0, &cert); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* NT40 */), - "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); ok(cert == NULL, "Expected NULL cert\n"); /* Check whether cbDecoded is set on error */ cbDecoded = 0xdeadbeef; ret = CryptVerifyMessageSignature(¶, 0, NULL, 0, NULL, &cbDecoded, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_BAD_ARG /* NT40 */), - "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); ok(!cbDecoded, "Expected 0\n"); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, dataEmptyBareContent, sizeof(dataEmptyBareContent), NULL, 0, NULL); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* NT40 */), - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); - ok(GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH, /* win9x */ - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); + ok(GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, dataEmptyContent, sizeof(dataEmptyContent), NULL, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE, - "Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedEmptyBareContent, sizeof(signedEmptyBareContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedEmptyContent, sizeof(signedEmptyContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptVerifyMessageSignature(¶, 0, signedContent, sizeof(signedContent), NULL, 0, NULL); - ok(!ret && - (GetLastError() == CRYPT_E_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR), /* win9x */ - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* FIXME: Windows fails with CRYPT_E_NOT_FOUND for these messages, but * their signer certs have invalid public keys that fail to decode. In * Wine therefore the failure is an ASN error. Need some messages with @@ -616,22 +569,22 @@ static void test_verify_message_signature(void) ret = CryptVerifyMessageSignature(¶, 0, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL); - ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError()); - ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded); + ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError()); + ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded); cbDecoded = 0; ret = CryptVerifyMessageSignature(¶, 0, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL); /* Setting cbDecoded to 0 succeeds when a NULL buffer is provided */ - ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError()); - ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded); + ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError()); + ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded); cbDecoded = 0; ret = CryptVerifyMessageSignature(¶, 0, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), decoded, &cbDecoded, NULL); /* When a non-NULL buffer is provided, cbDecoded must not be too small */ ok(!ret && GetLastError() == ERROR_MORE_DATA, - "expected ERROR_MORE_DATA, got %d (%08x)\n", GetLastError(), + "expected ERROR_MORE_DATA, got %ld (%08lx)\n", GetLastError(), GetLastError()); } @@ -670,38 +623,38 @@ static void test_hash_message(void) SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got 0x%08x\n", GetLastError()); + "expected E_INVALIDARG, got 0x%08lx\n", GetLastError()); para.cbSize = sizeof(para); /* Not quite sure what "success" means in this case, but it does succeed */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* With a bogus encoding type it "succeeds" */ para.dwMsgEncodingType = 0xdeadbeef; SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* According to MSDN, the third parameter (cToBeHashed) must be 1 if the * second parameter (fDetached) is FALSE, but again it "succeeds." */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* Even passing parameters to hash results in "success." */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 2, toHash, hashSize, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* Try again with a valid encoding type */ para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* And with valid data to hash */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 2, toHash, hashSize, NULL, NULL, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); /* But requesting the size of the hashed blob and indicating there's data * to hash results in a crash */ @@ -719,7 +672,7 @@ static void test_hash_message(void) ok(!ret && (GetLastError() == CRYPT_E_UNKNOWN_ALGO || GetLastError() == CRYPT_E_OID_FORMAT), /* Vista */ - "expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08x (%d)\n", + "expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08lx (%ld)\n", GetLastError(), GetLastError()); para.HashAlgorithm.pszObjId = oid_rsa_md5; /* With a valid hash algorithm, this succeeds, even though fDetached is @@ -729,55 +682,55 @@ static void test_hash_message(void) ret = CryptHashMessage(¶, FALSE, 2, toHash, hashSize, NULL, &hashedBlobSize, NULL, NULL); todo_wine - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); if (ret) { /* Actually attempting to get the hashed data fails, perhaps because * detached is FALSE. */ - hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize); + hashedBlob = malloc(hashedBlobSize); SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 2, toHash, hashSize, hashedBlob, &hashedBlobSize, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got 0x%08x (%d)\n", GetLastError(), + "expected CRYPT_E_MSG_ERROR, got 0x%08lx (%ld)\n", GetLastError(), GetLastError()); - HeapFree(GetProcessHeap(), 0, hashedBlob); + free(hashedBlob); } /* Repeating tests with fDetached = TRUE results in success */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, TRUE, 2, toHash, hashSize, NULL, &hashedBlobSize, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); if (ret) { - hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize); + hashedBlob = malloc(hashedBlobSize); SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, TRUE, 2, toHash, hashSize, hashedBlob, &hashedBlobSize, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); ok(hashedBlobSize == sizeof(detachedHashBlob), - "unexpected size of detached blob %d\n", hashedBlobSize); + "unexpected size of detached blob %ld\n", hashedBlobSize); ok(!memcmp(hashedBlob, detachedHashBlob, hashedBlobSize), "unexpected detached blob value\n"); - HeapFree(GetProcessHeap(), 0, hashedBlob); + free(hashedBlob); } /* Hashing a single item with fDetached = FALSE also succeeds */ SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, FALSE, 1, toHash, hashSize, NULL, &hashedBlobSize, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); if (ret) { - hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize); + hashedBlob = malloc(hashedBlobSize); ret = CryptHashMessage(¶, FALSE, 1, toHash, hashSize, hashedBlob, &hashedBlobSize, NULL, NULL); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); ok(hashedBlobSize == sizeof(hashBlob), - "unexpected size of detached blob %d\n", hashedBlobSize); + "unexpected size of detached blob %ld\n", hashedBlobSize); ok(!memcmp(hashedBlob, hashBlob, hashedBlobSize), "unexpected detached blob value\n"); - HeapFree(GetProcessHeap(), 0, hashedBlob); + free(hashedBlob); } /* Check the computed hash value too. You don't need to get the encoded * blob to get it. @@ -785,21 +738,21 @@ static void test_hash_message(void) computedHashSize = 0xdeadbeef; ret = CryptHashMessage(¶, TRUE, 2, toHash, hashSize, NULL, &hashedBlobSize, NULL, &computedHashSize); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); - ok(computedHashSize == 16, "expected hash size of 16, got %d\n", + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); + ok(computedHashSize == 16, "expected hash size of 16, got %ld\n", computedHashSize); if (ret) { - computedHash = HeapAlloc(GetProcessHeap(), 0, computedHashSize); + computedHash = malloc(computedHashSize); SetLastError(0xdeadbeef); ret = CryptHashMessage(¶, TRUE, 2, toHash, hashSize, NULL, &hashedBlobSize, computedHash, &computedHashSize); - ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError()); ok(computedHashSize == sizeof(hashVal), - "unexpected size of hash value %d\n", computedHashSize); + "unexpected size of hash value %ld\n", computedHashSize); ok(!memcmp(computedHash, hashVal, computedHashSize), "unexpected value\n"); - HeapFree(GetProcessHeap(), 0, computedHash); + free(computedHash); } } @@ -1013,7 +966,7 @@ static void test_sign_message(void) ok(!ret && (GetLastError() == E_INVALIDARG || GetLastError() == ERROR_ARITHMETIC_OVERFLOW), /* Win7 */ - "expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08x\n", + "expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08lx\n", GetLastError()); para.cbSize = sizeof(para); para.dwMsgEncodingType = X509_ASN_ENCODING; @@ -1021,37 +974,30 @@ static void test_sign_message(void) signedBlobSize = 255; ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - ok(!signedBlobSize, "unexpected size %d\n", signedBlobSize); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + ok(!signedBlobSize, "unexpected size %ld\n", signedBlobSize); para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); signedBlobSize = 0; ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); todo_wine ok(signedBlobSize, "bad size\n"); SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, + ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptImportKey(hCryptProv, publicPrivateKeyPair, sizeof(publicPrivateKeyPair), 0, 0, &hKey); - if (!ret && GetLastError() == NTE_PERM) /* Win9x */ - { - skip("Failed to import a key\n"); - if (hCryptProv) - CryptReleaseContext(hCryptProv, 0); - return; - } - ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); para.pSigningCert = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert1, sizeof(cert1)); - ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); para.HashAlgorithm.pszObjId = oid_rsa_md5; @@ -1062,21 +1008,21 @@ static void test_sign_message(void) SetLastError(0xdeadbeef); ret = CertSetCertificateContextProperty(para.pSigningCert, CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); signedBlobSize = 0; ret = CryptSignMessage(¶, TRUE, 0, NULL, NULL, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, TRUE, 0, NULL, NULL, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); ok(signedBlobSize == sizeof(signedHashForEmptyMessage), - "unexpected size %d\n", signedBlobSize); + "unexpected size %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedHashForEmptyMessage, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1085,15 +1031,15 @@ static void test_sign_message(void) SetLastError(0xdeadbeef); signedBlobSize = 0; ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %d\n", + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); + ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedEmptyMessage, signedBlobSize), "unexpected value\n"); @@ -1104,16 +1050,16 @@ static void test_sign_message(void) signedBlobSize = 0; ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); ok(signedBlobSize == sizeof(signedHash), - "unexpected size of signed blob %d\n", signedBlobSize); + "unexpected size of signed blob %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedHash, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1126,16 +1072,16 @@ static void test_sign_message(void) signedBlobSize = 0; ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); ok(signedBlobSize == sizeof(signedHashWithCert), - "unexpected size of signed blob %d\n", signedBlobSize); + "unexpected size of signed blob %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedHashWithCert, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1147,7 +1093,7 @@ static void test_sign_message(void) SetLastError(0xdeadbeef); crlContext = CertCreateCRLContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, crl, sizeof(crl)); - ok(crlContext != NULL, "CertCreateCRLContext failed: %08x\n", + ok(crlContext != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError()); para.rgpMsgCrl = &crlContext; @@ -1155,16 +1101,16 @@ static void test_sign_message(void) signedBlobSize = 0; ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); ok(signedBlobSize == sizeof(signedHashWithCRL), - "unexpected size of signed blob %d\n", signedBlobSize); + "unexpected size of signed blob %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedHashWithCRL, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1178,16 +1124,16 @@ static void test_sign_message(void) signedBlobSize = 0; ret = CryptSignMessage(¶, FALSE, 1, toSign, signSize, NULL, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); signedBlob = CryptMemAlloc(signedBlobSize); if (signedBlob) { SetLastError(0xdeadbeef); ret = CryptSignMessage(¶, FALSE, 1, toSign, signSize, signedBlob, &signedBlobSize); - ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError()); ok(signedBlobSize == sizeof(signedData), - "unexpected size of signed blob %d\n", signedBlobSize); + "unexpected size of signed blob %ld\n", signedBlobSize); ok(!memcmp(signedBlob, signedData, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1219,19 +1165,19 @@ static void test_encrypt_message(void) DWORD encryptedBlobSize; SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, + ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert1, sizeof(cert1)); - ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); certs[1] = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert2, sizeof(cert2)); - ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); memset(¶, 0, sizeof(para)); @@ -1240,8 +1186,8 @@ static void test_encrypt_message(void) ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize); para.cbSize = sizeof(para); para.dwMsgEncodingType = X509_ASN_ENCODING; SetLastError(0xdeadbeef); @@ -1249,19 +1195,17 @@ static void test_encrypt_message(void) ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize); para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); encryptedBlobSize = 255; ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); - ok(!ret && - (GetLastError() == CRYPT_E_UNKNOWN_ALGO || - GetLastError() == E_INVALIDARG), /* Win9x */ - "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n", + ok(!ret && GetLastError() == CRYPT_E_UNKNOWN_ALGO, + "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n", GetLastError()); - ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize); + ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize); para.hCryptProv = hCryptProv; para.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4; @@ -1270,9 +1214,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL, &encryptedBlobSize); - ok(ret || - broken(!ret) /* Win9x */, - "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1281,9 +1223,9 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, encryptedBlob, &encryptedBlobSize); - ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError()); - ok(encryptedBlobSize == sizeof(encryptedMessage), - "unexpected size of encrypted blob %d\n", encryptedBlobSize); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); + ok(encryptedBlobSize == sizeof(encryptedMessage), + "unexpected size of encrypted blob %ld\n", encryptedBlobSize); ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize), "unexpected value\n"); CryptMemFree(encryptedBlob); @@ -1294,7 +1236,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 2, certs, NULL, 0, NULL, &encryptedBlobSize); - ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1303,7 +1245,7 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 2, certs, NULL, 0, encryptedBlob, &encryptedBlobSize); - ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); CryptMemFree(encryptedBlob); } } @@ -1312,9 +1254,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob), NULL, &encryptedBlobSize); - ok(ret || - broken(!ret) /* Win9x */, - "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1323,13 +1263,11 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob), encryptedBlob, &encryptedBlobSize); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { ok(encryptedBlobSize == 55, - "unexpected size of encrypted blob %d\n", encryptedBlobSize); + "unexpected size of encrypted blob %ld\n", encryptedBlobSize); } CryptMemFree(encryptedBlob); } @@ -1339,7 +1277,7 @@ static void test_encrypt_message(void) encryptedBlobSize = 0; ret = CryptEncryptMessage(¶, 2, certs, blob, sizeof(blob), NULL, &encryptedBlobSize); - ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); if (ret) { encryptedBlob = CryptMemAlloc(encryptedBlobSize); @@ -1348,9 +1286,7 @@ static void test_encrypt_message(void) SetLastError(0xdeadbeef); ret = CryptEncryptMessage(¶, 2, certs, blob, sizeof(blob), encryptedBlob, &encryptedBlobSize); - ok(ret || - broken(!ret), /* some Win95 and some NT4 */ - "CryptEncryptMessage failed: %08x\n", GetLastError()); + ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError()); CryptMemFree(encryptedBlob); } } @@ -1365,8 +1301,6 @@ static void test_encrypt_message(void) START_TEST(message) { - init_function_pointers(); - test_msg_get_signer_count(); test_verify_detached_message_hash(); test_verify_message_hash(); diff --git a/modules/rostests/winetests/crypt32/msg.c b/modules/rostests/winetests/crypt32/msg.c index b6921273eea..4da5e239a7f 100644 --- a/modules/rostests/winetests/crypt32/msg.c +++ b/modules/rostests/winetests/crypt32/msg.c @@ -29,30 +29,8 @@ #include "wine/test.h" -static BOOL have_nt = TRUE; -static BOOL old_crypt32 = FALSE; static char oid_rsa_md5[] = szOID_RSA_MD5; -static BOOL (WINAPI * pCryptAcquireContextA) - (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); -static BOOL (WINAPI * pCryptAcquireContextW) - (HCRYPTPROV *, LPCWSTR, LPCWSTR, DWORD, DWORD); - -static void init_function_pointers(void) -{ - HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll"); - -#define GET_PROC(dll, func) \ - p ## func = (void *)GetProcAddress(dll, #func); \ - if(!p ## func) \ - trace("GetProcAddress(%s) failed\n", #func); - - GET_PROC(hAdvapi32, CryptAcquireContextA) - GET_PROC(hAdvapi32, CryptAcquireContextW) - -#undef GET_PROC -} - static void test_msg_open_to_encode(void) { HCRYPTMSG msg; @@ -70,32 +48,32 @@ static void test_msg_open_to_encode(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(0, 0, 0, NULL, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); /* Bad message types */ SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, 0, NULL, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, 0, NULL, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED_AND_ENVELOPED, NULL, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, NULL, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); } static void test_msg_open_to_decode(void) @@ -106,50 +84,50 @@ static void test_msg_open_to_decode(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToDecode(0, 0, 0, 0, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); /* Bad encodings */ SetLastError(0xdeadbeef); msg = CryptMsgOpenToDecode(X509_ASN_ENCODING, 0, 0, 0, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); msg = CryptMsgOpenToDecode(X509_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); /* The message type can be explicit... */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED_AND_ENVELOPED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* or implicit.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* or even invalid. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* And even though the stream info parameter "must be set to NULL" for @@ -157,7 +135,7 @@ static void test_msg_open_to_decode(void) */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, &streamInfo); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -175,95 +153,95 @@ static void test_msg_get_param(void) /* Decoded messages */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); /* For decoded messages, the type is always available */ size = 0; ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); /* For this (empty) message, the type isn't set */ - ok(value == 0, "Expected type 0, got %d\n", value); + ok(value == 0, "Expected type 0, got %ld\n", value); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); /* For explicitly typed messages, the type is known. */ size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == CMSG_DATA, "Expected CMSG_DATA, got %d\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == CMSG_DATA, "Expected CMSG_DATA, got %ld\n", value); + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); - ok(!ret, "Parameter %d: expected failure\n", i); + ok(!ret, "Parameter %ld: expected failure\n", i); } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %ld\n", value); + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); - ok(!ret, "Parameter %d: expected failure\n", i); + ok(!ret, "Parameter %ld: expected failure\n", i); } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %ld\n", value); + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); - ok(!ret, "Parameter %d: expected failure\n", i); + ok(!ret, "Parameter %ld: expected failure\n", i); } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value); - for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++) + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %ld\n", value); + for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; ret = CryptMsgGetParam(msg, i, 0, NULL, &size); - ok(!ret, "Parameter %d: expected failure\n", i); + ok(!ret, "Parameter %ld: expected failure\n", i); } CryptMsgClose(msg); /* Explicitly typed messages get their types set, even if they're invalid */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %ld\n", value); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); - ok(value == 1000, "Expected 1000, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); + ok(value == 1000, "Expected 1000, got %ld\n", value); CryptMsgClose(msg); } @@ -274,15 +252,15 @@ static void test_msg_close(void) /* NULL succeeds.. */ ret = CryptMsgClose(NULL); - ok(ret, "CryptMsgClose failed: %x\n", GetLastError()); + ok(ret, "CryptMsgClose failed: %lx\n", GetLastError()); /* but an arbitrary pointer crashes. */ if (0) ret = CryptMsgClose((HCRYPTMSG)1); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); ret = CryptMsgClose(msg); - ok(ret, "CryptMsgClose failed: %x\n", GetLastError()); + ok(ret, "CryptMsgClose failed: %lx\n", GetLastError()); } static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param, @@ -294,22 +272,16 @@ static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param, size = 0xdeadbeef; ret = CryptMsgGetParam(msg, param, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */ || - GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x, for some params */), - "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError()); - if (!ret) - { - win_skip("parameter %d not supported, skipping tests\n", param); - return; - } - buf = HeapAlloc(GetProcessHeap(), 0, size); + ok(ret, "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError()); + + buf = malloc(size); ret = CryptMsgGetParam(msg, param, 0, buf, &size); - ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError()); - ok(size == expectedSize, "%s: expected size %d, got %d\n", test, + ok(ret, "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError()); + ok(size == expectedSize, "%s: expected size %ld, got %ld\n", test, expectedSize, size); if (size == expectedSize && size) ok(!memcmp(buf, expected, size), "%s: unexpected data\n", test); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } static void test_data_msg_open(void) @@ -324,34 +296,34 @@ static void test_data_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, &hashInfo, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* An empty stream info is allowed. */ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, &streamInfo); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* Passing a bogus inner OID succeeds for a non-streamed message.. */ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, oid, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* and still succeeds when CMSG_DETACHED_FLAG is passed.. */ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_DATA, NULL, oid, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* and when a stream info is given, even though you're not supposed to be * able to use anything but szOID_RSA_data when streaming is being used. */ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_DATA, NULL, oid, &streamInfo); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -377,28 +349,28 @@ static void test_data_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); /* Updating it with final = TRUE succeeds */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* Any subsequent update will fail, as the last was final */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); /* Starting with Vista, can update a message with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret || broken(!ret), "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); if (ret) { DWORD size; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) { LPBYTE buf = CryptMemAlloc(size); @@ -407,11 +379,11 @@ static void test_data_msg_update(void) { ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) { ok(size == sizeof(dataEmptyBareContent), - "unexpected size %d\n", size); + "unexpected size %ld\n", size); ok(!memcmp(buf, dataEmptyBareContent, size), "unexpected value\n"); } @@ -423,47 +395,31 @@ static void test_data_msg_update(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_DATA, NULL, NULL, NULL); - if (have_nt) - { - /* Doesn't appear to be able to update CMSG-DATA with non-final updates. - * On Win9x, this sometimes succeeds, sometimes fails with - * GetLastError() == 0, so it's not worth checking there. - */ - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && - (GetLastError() == E_INVALIDARG || - broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */ - "Expected E_INVALIDARG, got %x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && - (GetLastError() == E_INVALIDARG || - broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */ - "Expected E_INVALIDARG, got %x\n", GetLastError()); - } - else - skip("not updating CMSG_DATA with a non-final update\n"); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); + CryptMsgClose(msg); + + /* Calling update after opening with an empty stream info (with a bogus + * output function) yields an error: + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); CryptMsgClose(msg); - if (!old_crypt32) - { - /* Calling update after opening with an empty stream info (with a bogus - * output function) yields an error: - */ - /* Crashes on some Win9x */ - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, - &streamInfo); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n", - GetLastError()); - CryptMsgClose(msg); - } /* Calling update with a valid output function succeeds, even if the data * exceeds the size specified in the stream info. */ @@ -471,9 +427,9 @@ static void test_data_msg_update(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, &streamInfo); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -490,10 +446,10 @@ static void test_data_msg_get_param(void) /* Content and bare content are always gettable when not streaming */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = 0; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* But for this type of message, the signer and hash aren't applicable, * and the type isn't available. */ @@ -501,14 +457,14 @@ static void test_data_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); CryptMsgClose(msg); /* Can't get content or bare content when streaming */ @@ -516,12 +472,12 @@ static void test_data_msg_get_param(void) NULL, &streamInfo); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */), - "Expected E_INVALIDARG, got %x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */), - "Expected E_INVALIDARG, got %x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -605,18 +561,18 @@ static void check_updates(LPCSTR header, const struct update_accum *expected, DWORD i; ok(expected->cUpdates == got->cUpdates, - "%s: expected %d updates, got %d\n", header, expected->cUpdates, + "%s: expected %ld updates, got %ld\n", header, expected->cUpdates, got->cUpdates); if (expected->cUpdates == got->cUpdates) for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++) { ok(expected->updates[i].cbData == got->updates[i].cbData, - "%s, update %d: expected %d bytes, got %d\n", header, i, + "%s, update %ld: expected %ld bytes, got %ld\n", header, i, expected->updates[i].cbData, got->updates[i].cbData); if (expected->updates[i].cbData && expected->updates[i].cbData == got->updates[i].cbData) ok(!memcmp(expected->updates[i].pbData, got->updates[i].pbData, - got->updates[i].cbData), "%s, update %d: unexpected value\n", + got->updates[i].cbData), "%s, update %ld: unexpected value\n", header, i); } } @@ -648,7 +604,7 @@ static void test_data_msg_encoding(void) check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent, sizeof(dataEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM, dataBareContent, sizeof(dataBareContent)); check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, @@ -662,7 +618,7 @@ static void test_data_msg_encoding(void) check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent, sizeof(dataEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM, dataBareContent, sizeof(dataBareContent)); check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, @@ -676,7 +632,7 @@ static void test_data_msg_encoding(void) check_param("data bogus oid content", msg, CMSG_CONTENT_PARAM, dataEmptyContent, sizeof(dataEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM, dataBareContent, sizeof(dataBareContent)); check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, @@ -730,25 +686,25 @@ static void test_hash_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); hashInfo.cbSize = sizeof(hashInfo); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, - "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); + "Expected CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError()); hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_HASHED, &hashInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_HASHED, &hashInfo, NULL, &streamInfo); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -766,22 +722,22 @@ static void test_hash_msg_update(void) * updates.. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* including non-final updates with no data.. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* and final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* But no updates are allowed after the final update. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); CryptMsgClose(msg); /* Non-detached messages, in contrast, don't allow non-final updates in * non-streaming mode. @@ -791,16 +747,16 @@ static void test_hash_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); /* Final updates (including empty ones) are allowed. */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* And, of course, streaming mode allows non-final updates */ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, &streamInfo); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* Setting pfnStreamOutput to NULL results in no error. (In what appears * to be a bug, it isn't actually used - see encoding tests.) @@ -809,7 +765,7 @@ static void test_hash_msg_update(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, &streamInfo); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); } @@ -832,55 +788,46 @@ static void test_hash_msg_get_param(void) /* Content and bare content are always gettable for non-streamed messages */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = 0; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* For an encoded hash message, the hash data aren't available */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == CRYPT_E_INVALID_MSG_TYPE || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected CRYPT_E_INVALID_MSG_TYPE or OSS_LIMITED, got %08x\n", + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* The hash is also available. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(buf), "Unexpected size %d\n", size); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %ld\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(buf), "Unexpected size %d\n", size); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %ld\n", size); if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); /* By getting the hash, further updates are not allowed */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE /* NT */ || - GetLastError() == NTE_BAD_ALGID /* 9x */ || - GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ || - broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */), - "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), + "Expected CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError()); /* Even after a final update, the hash data aren't available */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* The version is also available, and should be zero for this message. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) - ok(value == 0, "Expected version 0, got %d\n", value); + ok(value == 0, "Expected version 0, got %ld\n", value); /* As usual, the type isn't available. */ ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); ok(!ret, "Expected failure\n"); @@ -891,21 +838,19 @@ static void test_hash_msg_get_param(void) /* Streamed messages don't allow you to get the content or bare content. */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(!ret && (GetLastError() == E_INVALIDARG || - GetLastError() == OSS_LIMITED /* Win9x */), - "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %lx\n", GetLastError()); /* The hash is still available. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(buf), "Unexpected size %d\n", size); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %ld\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); /* After updating the hash, further updates aren't allowed on streamed @@ -913,12 +858,8 @@ static void test_hash_msg_get_param(void) */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE /* NT */ || - GetLastError() == NTE_BAD_ALGID /* 9x */ || - GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ || - broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */), - "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), + "Expected CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError()); CryptMsgClose(msg); } @@ -979,7 +920,7 @@ static void test_hash_msg_encoding(void) check_param("hash empty content", msg, CMSG_CONTENT_PARAM, hashEmptyContent, sizeof(hashEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("hash bare content", msg, CMSG_BARE_CONTENT_PARAM, hashBareContent, sizeof(hashBareContent)); check_param("hash content", msg, CMSG_CONTENT_PARAM, @@ -993,7 +934,7 @@ static void test_hash_msg_encoding(void) check_param("hash empty content", msg, CMSG_CONTENT_PARAM, hashEmptyContent, sizeof(hashEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("hash bare content", msg, CMSG_BARE_CONTENT_PARAM, hashBareContent, sizeof(hashBareContent)); check_param("hash content", msg, CMSG_CONTENT_PARAM, @@ -1008,14 +949,14 @@ static void test_hash_msg_encoding(void) check_param("detached hash empty content", msg, CMSG_CONTENT_PARAM, hashEmptyContent, sizeof(hashEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("detached hash not final bare content", msg, CMSG_BARE_CONTENT_PARAM, detachedHashNonFinalBareContent, sizeof(detachedHashNonFinalBareContent)); check_param("detached hash not final content", msg, CMSG_CONTENT_PARAM, detachedHashNonFinalContent, sizeof(detachedHashNonFinalContent)); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); check_param("detached hash bare content", msg, CMSG_BARE_CONTENT_PARAM, detachedHashBareContent, sizeof(detachedHashBareContent)); check_param("detached hash content", msg, CMSG_CONTENT_PARAM, @@ -1031,9 +972,9 @@ static void test_hash_msg_encoding(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, &streamInfo); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); check_updates("empty hash message", &empty_accum, &accum); free_updates(&accum); @@ -1042,7 +983,7 @@ static void test_hash_msg_encoding(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, &streamInfo); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); check_updates("hash message", &empty_accum, &accum); free_updates(&accum); @@ -1051,7 +992,7 @@ static void test_hash_msg_encoding(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_HASHED, &hashInfo, NULL, &streamInfo); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); check_updates("detached hash message", &empty_accum, &accum); free_updates(&accum); @@ -1067,8 +1008,6 @@ static void test_hash_msg(void) static const CHAR cspNameA[] = { 'W','i','n','e','C','r','y','p','t','T','e', 'm','p',0 }; -static const WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e', - 'm','p',0 }; static BYTE serialNum[] = { 1 }; static BYTE encodedCommonName[] = { 0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03, 0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 }; @@ -1085,11 +1024,11 @@ static void test_signed_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %x\n", GetLastError()); + "Expected E_INVALIDARG, got %lx\n", GetLastError()); signInfo.cbSize = sizeof(signInfo); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); signInfo.cSigners = 1; @@ -1105,7 +1044,7 @@ static void test_signed_msg_open(void) /* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */ ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef || GetLastError() == CRYPT_E_UNKNOWN_ALGO), - "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n", + "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%lx\n", GetLastError()); certInfo.SerialNumber.cbData = sizeof(serialNum); @@ -1113,20 +1052,16 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - /* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */ - ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef - || GetLastError() == CRYPT_E_UNKNOWN_ALGO), - "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n", - GetLastError()); + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got 0x%lx\n", GetLastError()); certInfo.Issuer.cbData = sizeof(encodedCommonName); certInfo.Issuer.pbData = encodedCommonName; SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(!msg && (GetLastError() == E_INVALIDARG || - GetLastError() == CRYPT_E_UNKNOWN_ALGO), - "Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); + ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == CRYPT_E_UNKNOWN_ALGO), + "Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError()); /* The signer's hCryptProv must be set to something. Whether it's usable * or not will be checked after the hash algorithm is checked (see next @@ -1137,7 +1072,7 @@ static void test_signed_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, - "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); + "Expected CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError()); /* The signer's hash algorithm must also be set. */ signer.HashAlgorithm.pszObjId = oid_rsa_md5; SetLastError(0xdeadbeef); @@ -1146,21 +1081,21 @@ static void test_signed_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); ok(!msg && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %lx\n", GetLastError()); } /* The signer's hCryptProv must also be valid. */ - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } - ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); + ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError()); if (ret) { msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); } @@ -1170,19 +1105,17 @@ static void test_signed_msg_open(void) certInfo.Issuer.cbData = 0; certInfo.SerialNumber.cbData = 0; signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; - U(signer.SignerId).IssuerSerialNumber.Issuer.cbData = - sizeof(encodedCommonName); - U(signer.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonName; - U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData = - sizeof(serialNum); - U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum; + signer.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonName); + signer.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonName; + signer.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); + signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = serialNum; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgClose(msg); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } @@ -1236,101 +1169,105 @@ static void test_signed_msg_update(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } - ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); - - if (!ret) { - skip("No context for tests\n"); - return; - } + ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* Detached CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* Detached CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* The final update requires a private key in the hCryptProv, in order to * generate the signature. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && - (GetLastError() == NTE_BAD_KEYSET || - GetLastError() == NTE_NO_KEY || - broken(GetLastError() == ERROR_SUCCESS)), /* Some Win9x */ - "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %x\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_KEYSET || GetLastError() == NTE_NO_KEY), + "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %lx\n", GetLastError()); ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey), 0, 0, &key); - ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); /* The final update should be able to succeed now that a key exists, but * the previous (invalid) final update prevents it. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* Detached CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* Detached CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* Now that the private key exists, the final update can succeed (even * with no data.) */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* But no updates are allowed after the final update. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* Non-detached messages don't allow non-final updates.. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); /* but they do allow final ones. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* They also allow final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); CryptDestroyKey(key); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } +static const BYTE unsignedEmptyBareContent[] = { +0x30,0x0b,0x02,0x01,0x01,0x31,0x00,0x30,0x02,0x06,0x00,0x31,0x00 }; +static const BYTE unsignedEmptyContent[] = { +0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,0x0d, +0x30,0x0b,0x02,0x01,0x01,0x31,0x00,0x30,0x02,0x06,0x00,0x31,0x00 }; +static const BYTE detachedUnsignedBareContent[] = { +0x30,0x14,0x02,0x01,0x01,0x31,0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86, +0xf7,0x0d,0x01,0x07,0x01,0x31,0x00 }; +static const BYTE detachedUnsignedContent[] = { +0x30,0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,0x16, +0x30,0x14,0x02,0x01,0x01,0x31,0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86, +0xf7,0x0d,0x01,0x07,0x01,0x31,0x00 }; static const BYTE signedEmptyBareContent[] = { 0x30,0x50,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86, 0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x02,0x06,0x00,0x31,0x37,0x30,0x35,0x02, @@ -1665,6 +1602,32 @@ static void test_signed_msg_encoding(void) HCRYPTKEY key; DWORD size; + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, + CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); + + check_param("detached unsigned empty bare content", msg, + CMSG_BARE_CONTENT_PARAM, unsignedEmptyBareContent, + sizeof(unsignedEmptyBareContent)); + check_param("detached unsigned empty content", msg, CMSG_CONTENT_PARAM, + unsignedEmptyContent, sizeof(unsignedEmptyContent)); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); + check_param("detached unsigned bare content", msg, CMSG_BARE_CONTENT_PARAM, + detachedUnsignedBareContent, sizeof(detachedUnsignedBareContent)); + check_param("detached unsigned content", msg, CMSG_CONTENT_PARAM, + detachedUnsignedContent, sizeof(detachedUnsignedContent)); + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); + ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); + + CryptMsgClose(msg); + certInfo.SerialNumber.cbData = sizeof(serialNum); certInfo.SerialNumber.pbData = serialNum; certInfo.Issuer.cbData = sizeof(encodedCommonName); @@ -1674,26 +1637,21 @@ static void test_signed_msg_encoding(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } - ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); - - if (!ret) { - skip("No context for tests\n"); - return; - } + ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError()); ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey), 0, 0, &key); - ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("detached signed empty bare content", msg, CMSG_BARE_CONTENT_PARAM, signedEmptyBareContent, @@ -1701,7 +1659,7 @@ static void test_signed_msg_encoding(void) check_param("detached signed empty content", msg, CMSG_CONTENT_PARAM, signedEmptyContent, sizeof(signedEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("detached signed hash", msg, CMSG_COMPUTED_HASH_PARAM, signedHash, sizeof(signedHash)); check_param("detached signed bare content", msg, CMSG_BARE_CONTENT_PARAM, @@ -1710,9 +1668,8 @@ static void test_signed_msg_encoding(void) detachedSignedContent, sizeof(detachedSignedContent)); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size); - ok(!ret && (GetLastError() == CRYPT_E_INVALID_INDEX || - broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */)), - "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); check_param("detached signed encoded signer", msg, CMSG_ENCODED_SIGNER, signedEncodedSigner, sizeof(signedEncodedSigner)); @@ -1721,11 +1678,11 @@ static void test_signed_msg_encoding(void) certInfo.SerialNumber.cbData = 0; certInfo.Issuer.cbData = 0; signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER; - U(signer.SignerId).KeyId.cbData = sizeof(serialNum); - U(signer.SignerId).KeyId.pbData = serialNum; + signer.SignerId.KeyId.cbData = sizeof(serialNum); + signer.SignerId.KeyId.pbData = serialNum; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signed key id empty content", msg, CMSG_CONTENT_PARAM, signedKeyIdEmptyContent, sizeof(signedKeyIdEmptyContent)); CryptMsgClose(msg); @@ -1737,14 +1694,14 @@ static void test_signed_msg_encoding(void) signer.SignerId.dwIdChoice = 0; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signed empty bare content", msg, CMSG_BARE_CONTENT_PARAM, signedEmptyBareContent, sizeof(signedEmptyBareContent)); check_param("signed empty content", msg, CMSG_CONTENT_PARAM, signedEmptyContent, sizeof(signedEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("signed bare content", msg, CMSG_BARE_CONTENT_PARAM, signedBareContent, sizeof(signedBareContent)); check_param("signed content", msg, CMSG_CONTENT_PARAM, @@ -1756,7 +1713,7 @@ static void test_signed_msg_encoding(void) signer.rgAuthAttr = &attr; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); check_param("signed with auth attrs bare content", msg, @@ -1770,13 +1727,13 @@ static void test_signed_msg_encoding(void) signInfo.cCertEncoded = 1; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signed with cert empty bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCertEmptyBareContent, sizeof(signedWithCertEmptyBareContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("signed with cert bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCertBareContent, sizeof(signedWithCertBareContent)); @@ -1787,13 +1744,13 @@ static void test_signed_msg_encoding(void) signInfo.cCrlEncoded = 1; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signed with crl empty bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCrlEmptyBareContent, sizeof(signedWithCrlEmptyBareContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("signed with crl bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCrlBareContent, sizeof(signedWithCrlBareContent)); @@ -1802,13 +1759,13 @@ static void test_signed_msg_encoding(void) signInfo.cCertEncoded = 1; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signed with cert and crl empty bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCertAndCrlEmptyBareContent, sizeof(signedWithCertAndCrlEmptyBareContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); check_param("signed with cert and crl bare content", msg, CMSG_BARE_CONTENT_PARAM, signedWithCertAndCrlBareContent, sizeof(signedWithCertAndCrlBareContent)); @@ -1821,7 +1778,7 @@ static void test_signed_msg_encoding(void) encodedCert.pbData = v1CertWithPubKey; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signedWithCertWithPubKeyBareContent", msg, CMSG_BARE_CONTENT_PARAM, signedWithCertWithPubKeyBareContent, sizeof(signedWithCertWithPubKeyBareContent)); @@ -1831,12 +1788,12 @@ static void test_signed_msg_encoding(void) encodedCert.pbData = v1CertWithValidPubKey; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); check_param("signedWithCertWithValidPubKeyEmptyContent", msg, CMSG_CONTENT_PARAM, signedWithCertWithValidPubKeyEmptyContent, sizeof(signedWithCertWithValidPubKeyEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); check_param("signedWithCertWithValidPubKeyContent", msg, CMSG_CONTENT_PARAM, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent)); @@ -1844,7 +1801,7 @@ static void test_signed_msg_encoding(void) CryptDestroyKey(key); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } @@ -1859,29 +1816,24 @@ static void test_signed_msg_get_param(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* Content and bare content are always gettable */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); - ok(ret || broken(!ret /* Win9x */), "CryptMsgGetParam failed: %08x\n", - GetLastError()); - if (!ret) - { - skip("message parameters are broken, skipping tests\n"); - return; - } + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + size = 0; ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* For "signed" messages, so is the version. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == CMSG_SIGNED_DATA_V1, "Expected version 1, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == CMSG_SIGNED_DATA_V1, "Expected version 1, got %ld\n", value); /* But for this message, with no signers, the hash and signer aren't * available. */ @@ -1889,15 +1841,15 @@ static void test_signed_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); /* As usual, the type isn't available. */ ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); CryptMsgClose(msg); @@ -1910,44 +1862,39 @@ static void test_signed_msg_get_param(void) signInfo.cSigners = 1; signInfo.rgSigners = &signer; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); } - ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError()); - - if (!ret) { - skip("No context for tests\n"); - return; - } + ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* This message, with one signer, has the hash and signer for index 0 * available, but not for other indexes. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError()); size = 0; SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 1, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError()); /* As usual, the type isn't available. */ ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); CryptMsgClose(msg); @@ -1955,88 +1902,85 @@ static void test_signed_msg_get_param(void) certInfo.SerialNumber.cbData = 0; certInfo.Issuer.cbData = 0; signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; - U(signer.SignerId).IssuerSerialNumber.Issuer.cbData = - sizeof(encodedCommonName); - U(signer.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonName; - U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData = - sizeof(serialNum); - U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + signer.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonName); + signer.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonName; + signer.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); + signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = serialNum; + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); - ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError()); + ok(ret, "CryptAcquireContextA failed: %lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_CRYPT_RELEASE_CONTEXT_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); /* still results in the version being 1 when the issuer and serial number * are used and no additional CMS fields are used. */ size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE), - "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) - ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %d\n", value); + ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %ld\n", value); /* Apparently the encoded signer can be retrieved.. */ ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* but the signer info, CMS signer info, and cert ID can't be. */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_ID_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); CryptMsgClose(msg); /* Using the KeyId field of the SignerId results in the version becoming * the CMS version. */ signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER; - U(signer.SignerId).KeyId.cbData = sizeof(serialNum); - U(signer.SignerId).KeyId.pbData = serialNum; - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + signer.SignerId.KeyId.cbData = sizeof(serialNum); + signer.SignerId.KeyId.pbData = serialNum; + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) - ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, + ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL, PROV_RSA_FULL, 0); - ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError()); + ok(ret, "CryptAcquireContextA failed: %lx\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_CRYPT_RELEASE_CONTEXT_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); if (ret) - ok(value == CMSG_SIGNED_DATA_V3, "expected version 3, got %d\n", value); + ok(value == CMSG_SIGNED_DATA_V3, "expected version 3, got %ld\n", value); /* Even for a CMS message, the signer can be retrieved.. */ ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); /* but the signer info, CMS signer info, and cert ID can't be. */ SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_ID_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); CryptMsgClose(msg); CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, + CryptAcquireContextA(&signer.hCryptProv, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } @@ -2061,60 +2005,49 @@ static void test_enveloped_msg_open(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); ok(!msg && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); envelopedInfo.cbSize = sizeof(envelopedInfo); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(!msg && - (GetLastError() == CRYPT_E_UNKNOWN_ALGO || - GetLastError() == E_INVALIDARG), /* Win9x */ - "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n", GetLastError()); + ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, + "expected CRYPT_E_UNKNOWN_ALGO, got %08lx\n", GetLastError()); envelopedInfo.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4; SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); CryptMsgClose(msg); envelopedInfo.cRecipients = 1; - if (!old_crypt32) - { - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(!msg && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - } + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(!msg && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); context = CertCreateCertificateContext(X509_ASN_ENCODING, v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey)); - if (context) - { - envelopedInfo.rgpRecipientCert = (PCERT_INFO *)&context->pCertInfo; - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - SetLastError(0xdeadbeef); - ret = pCryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, - &envelopedInfo, NULL, NULL); - ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - CryptReleaseContext(envelopedInfo.hCryptProv, 0); - CertFreeCertificateContext(context); - } - else - win_skip("failed to create certificate context, skipping tests\n"); + + envelopedInfo.rgpRecipientCert = (PCERT_INFO *)&context->pCertInfo; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); + ret = CryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, + &envelopedInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + CryptReleaseContext(envelopedInfo.hCryptProv, 0); + CertFreeCertificateContext(context); } static void test_enveloped_msg_update(void) @@ -2128,117 +2061,92 @@ static void test_enveloped_msg_update(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == E_INVALIDARG, + "expected E_INVALIDARG, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, &streamInfo); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); + SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, &streamInfo); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */ - "CryptMsgUpdate failed: %08x\n", GetLastError()); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); + CryptMsgClose(msg); } static const BYTE envelopedEmptyBareContent[] = { @@ -2260,18 +2168,13 @@ static void test_enveloped_msg_encoding(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); - ok(msg != NULL || - broken(!msg), /* Win9x */ - "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); - if (msg) - { - check_param("enveloped empty bare content", msg, - CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent, - sizeof(envelopedEmptyBareContent)); - check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, - envelopedEmptyContent, sizeof(envelopedEmptyContent)); - CryptMsgClose(msg); - } + ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError()); + check_param("enveloped empty bare content", msg, + CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent, + sizeof(envelopedEmptyBareContent)); + check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, + envelopedEmptyContent, sizeof(envelopedEmptyContent)); + CryptMsgClose(msg); } static void test_enveloped_msg(void) @@ -2321,12 +2224,12 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); /* Update with a full message in a final update */ ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* Can't update after a final update */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); @@ -2335,50 +2238,40 @@ static void test_decode_msg_update(void) ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), FALSE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError()); /* A subsequent final update succeeds */ ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); - if (!old_crypt32) - { - msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); - /* Updating a message that has a NULL stream callback fails */ - SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ - ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), - FALSE); - todo_wine - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n", - GetLastError()); - /* Changing the callback pointer after the fact yields the same error (so - * the message must copy the stream info, not just store a pointer to it) - */ - streamInfo.pfnStreamOutput = nop_stream_output; - SetLastError(0xdeadbeef); - ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), - FALSE); - todo_wine - ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION || - GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */), - "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n", - GetLastError()); - CryptMsgClose(msg); - } + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + /* Updating a message that has a NULL stream callback fails */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError()); + /* Changing the callback pointer after the fact yields the same error (so + * the message must copy the stream info, not just store a pointer to it) + */ + streamInfo.pfnStreamOutput = nop_stream_output; + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n", GetLastError()); + CryptMsgClose(msg); /* Empty non-final updates are allowed when streaming.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); /* but final updates aren't when not enough data has been received. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); todo_wine ok(!ret && GetLastError() == CRYPT_E_STREAM_INSUFFICIENT_DATA, - "Expected CRYPT_E_STREAM_INSUFFICIENT_DATA, got %x\n", GetLastError()); + "Expected CRYPT_E_STREAM_INSUFFICIENT_DATA, got %lx\n", GetLastError()); CryptMsgClose(msg); /* Updating the message byte by byte is legal */ @@ -2387,9 +2280,9 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); for (i = 0, ret = TRUE; ret && i < sizeof(dataEmptyContent); i++) ret = CryptMsgUpdate(msg, &dataEmptyContent[i], 1, FALSE); - ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); + ok(ret, "CryptMsgUpdate failed on byte %ld: %lx\n", i, GetLastError()); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); + ok(ret, "CryptMsgUpdate failed on byte %ld: %lx\n", i, GetLastError()); CryptMsgClose(msg); todo_wine check_updates("byte-by-byte empty content", &a4, &accum); @@ -2399,9 +2292,8 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and as the final update in streaming mode.. */ @@ -2409,9 +2301,8 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and even as a non-final update in streaming mode. */ @@ -2420,17 +2311,15 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); todo_wine - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* An empty message can be opened with undetermined type.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* but decoding it as an explicitly typed message fails. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, @@ -2438,10 +2327,8 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* On the other hand, decoding the bare content of an empty message fails * with unspecified type.. @@ -2450,17 +2337,15 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, dataEmptyBareContent, sizeof(dataEmptyBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); ret = CryptMsgUpdate(msg, dataEmptyBareContent, sizeof(dataEmptyBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* Decoding valid content with an unsupported OID fails */ @@ -2468,26 +2353,22 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, bogusOIDContent, sizeof(bogusOIDContent), TRUE); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); CryptMsgClose(msg); /* Similarly, opening an empty hash with unspecified type succeeds.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); /* while with specified type it fails. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* On the other hand, decoding the bare content of an empty hash message * fails with unspecified type.. @@ -2496,19 +2377,15 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win9x */), - "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* And again, opening a (non-empty) hash message with unspecified type @@ -2517,18 +2394,15 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); /* while with specified type it fails.. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* and decoding the bare content of a non-empty hash message fails with * unspecified type.. @@ -2536,17 +2410,15 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ || - GetLastError() == OSS_DATA_ERROR /* some Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n", + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %lx\n", GetLastError()); CryptMsgClose(msg); /* but succeeds with explicit type. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError()); CryptMsgClose(msg); /* Opening a (non-empty) hash message with unspecified type and a bogus @@ -2555,27 +2427,25 @@ static void test_decode_msg_update(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, bogusHashContent, sizeof(bogusHashContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent, sizeof(signedWithCertAndCrlBareContent), TRUE); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent, sizeof(signedWithCertAndCrlBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0, @@ -2583,31 +2453,31 @@ static void test_decode_msg_update(void) /* The first update succeeds.. */ ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* as does a second (probably to update the detached portion).. */ ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* while a third fails. */ ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0, NULL, &streamInfo); ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), FALSE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), FALSE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, - "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError()); + "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -2615,7 +2485,7 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyBareContent, sizeof(envelopedEmptyBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -2623,27 +2493,23 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyContent, sizeof(envelopedEmptyContent), TRUE); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* Win9x */ - "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyBareContent, sizeof(envelopedEmptyBareContent), TRUE); - ok(!ret && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - GetLastError() == OSS_DATA_ERROR), /* Win9x */ - "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyContent, sizeof(envelopedEmptyContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -2651,7 +2517,7 @@ static void test_decode_msg_update(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedBareContentWithoutData, sizeof(envelopedBareContentWithoutData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); CryptMsgClose(msg); } @@ -2661,15 +2527,15 @@ static const BYTE hashParam[] = { 0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1, static void compare_signer_info(const CMSG_SIGNER_INFO *got, const CMSG_SIGNER_INFO *expected) { - ok(got->dwVersion == expected->dwVersion, "Expected version %d, got %d\n", + ok(got->dwVersion == expected->dwVersion, "Expected version %ld, got %ld\n", expected->dwVersion, got->dwVersion); ok(got->Issuer.cbData == expected->Issuer.cbData, - "Expected issuer size %d, got %d\n", expected->Issuer.cbData, + "Expected issuer size %ld, got %ld\n", expected->Issuer.cbData, got->Issuer.cbData); ok(!memcmp(got->Issuer.pbData, expected->Issuer.pbData, got->Issuer.cbData), "Unexpected issuer\n"); ok(got->SerialNumber.cbData == expected->SerialNumber.cbData, - "Expected serial number size %d, got %d\n", expected->SerialNumber.cbData, + "Expected serial number size %ld, got %ld\n", expected->SerialNumber.cbData, got->SerialNumber.cbData); ok(!memcmp(got->SerialNumber.pbData, expected->SerialNumber.pbData, got->SerialNumber.cbData), "Unexpected serial number\n"); @@ -2679,41 +2545,41 @@ static void compare_signer_info(const CMSG_SIGNER_INFO *got, static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got, const CMSG_CMS_SIGNER_INFO *expected) { - ok(got->dwVersion == expected->dwVersion, "Expected version %d, got %d\n", + ok(got->dwVersion == expected->dwVersion, "Expected version %ld, got %ld\n", expected->dwVersion, got->dwVersion); ok(got->SignerId.dwIdChoice == expected->SignerId.dwIdChoice, - "Expected id choice %d, got %d\n", expected->SignerId.dwIdChoice, + "Expected id choice %ld, got %ld\n", expected->SignerId.dwIdChoice, got->SignerId.dwIdChoice); if (got->SignerId.dwIdChoice == expected->SignerId.dwIdChoice) { if (got->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER) { - ok(U(got->SignerId).IssuerSerialNumber.Issuer.cbData == - U(expected->SignerId).IssuerSerialNumber.Issuer.cbData, - "Expected issuer size %d, got %d\n", - U(expected->SignerId).IssuerSerialNumber.Issuer.cbData, - U(got->SignerId).IssuerSerialNumber.Issuer.cbData); - ok(!memcmp(U(got->SignerId).IssuerSerialNumber.Issuer.pbData, - U(expected->SignerId).IssuerSerialNumber.Issuer.pbData, - U(got->SignerId).IssuerSerialNumber.Issuer.cbData), + ok(got->SignerId.IssuerSerialNumber.Issuer.cbData == + expected->SignerId.IssuerSerialNumber.Issuer.cbData, + "Expected issuer size %ld, got %ld\n", + expected->SignerId.IssuerSerialNumber.Issuer.cbData, + got->SignerId.IssuerSerialNumber.Issuer.cbData); + ok(!memcmp(got->SignerId.IssuerSerialNumber.Issuer.pbData, + expected->SignerId.IssuerSerialNumber.Issuer.pbData, + got->SignerId.IssuerSerialNumber.Issuer.cbData), "Unexpected issuer\n"); - ok(U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData == - U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData, - "Expected serial number size %d, got %d\n", - U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData, - U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData); - ok(!memcmp(U(got->SignerId).IssuerSerialNumber.SerialNumber.pbData, - U(expected->SignerId).IssuerSerialNumber.SerialNumber.pbData, - U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData), + ok(got->SignerId.IssuerSerialNumber.SerialNumber.cbData == + expected->SignerId.IssuerSerialNumber.SerialNumber.cbData, + "Expected serial number size %ld, got %ld\n", + expected->SignerId.IssuerSerialNumber.SerialNumber.cbData, + got->SignerId.IssuerSerialNumber.SerialNumber.cbData); + ok(!memcmp(got->SignerId.IssuerSerialNumber.SerialNumber.pbData, + expected->SignerId.IssuerSerialNumber.SerialNumber.pbData, + got->SignerId.IssuerSerialNumber.SerialNumber.cbData), "Unexpected serial number\n"); } else { - ok(U(got->SignerId).KeyId.cbData == U(expected->SignerId).KeyId.cbData, - "expected key id size %d, got %d\n", - U(expected->SignerId).KeyId.cbData, U(got->SignerId).KeyId.cbData); - ok(!memcmp(U(expected->SignerId).KeyId.pbData, - U(got->SignerId).KeyId.pbData, U(got->SignerId).KeyId.cbData), + ok(got->SignerId.KeyId.cbData == expected->SignerId.KeyId.cbData, + "expected key id size %ld, got %ld\n", + expected->SignerId.KeyId.cbData, got->SignerId.KeyId.cbData); + ok(!memcmp(expected->SignerId.KeyId.pbData, + got->SignerId.KeyId.pbData, got->SignerId.KeyId.cbData), "unexpected key id\n"); } } @@ -2865,48 +2731,40 @@ static void test_decode_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError()); ret = CryptMsgUpdate(msg, dataContent, sizeof(dataContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); check_param("data content", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE); - if (ret) - { - /* Crashes on some Win9x */ - check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0); - check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0); - check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, - emptyHashParam, sizeof(emptyHashParam)); - } + + check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0); + check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0); + check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, + emptyHashParam, sizeof(emptyHashParam)); + CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); check_param("hash content", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); check_param("hash hash data", msg, CMSG_HASH_DATA_PARAM, hashParam, sizeof(hashParam)); check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM, hashParam, sizeof(hashParam)); - /* Curiously, on NT-like systems, getting the hash of index 1 succeeds, - * even though there's only one hash. - */ + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size); - ok(ret || GetLastError() == OSS_DATA_ERROR /* Win9x */, - "CryptMsgGetParam failed: %08x\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(hashParam), "Unexpected size %d\n", size); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(size == sizeof(hashParam), "Unexpected size %ld\n", size); ok(!memcmp(buf, hashParam, size), "Unexpected value\n"); CryptMemFree(buf); } @@ -2919,7 +2777,7 @@ static void test_decode_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); check_param("signed content", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); check_param("inner content", msg, CMSG_INNER_CONTENT_TYPE_PARAM, @@ -2927,16 +2785,12 @@ static void test_decode_msg_get_param(void) size = sizeof(value); value = 2112; ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 1, "Expected 1 signer, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 1, "Expected 1 signer, got %ld\n", value); size = 0; ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_SIGNER_INFO signer = { 0 }; @@ -2950,31 +2804,25 @@ static void test_decode_msg_get_param(void) req_size = size; size += 10; CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, buf, &size); - ok(size == req_size, "size = %u, expected %u\n", size, req_size); + ok(size == req_size, "size = %lu, expected %lu\n", size, req_size); compare_signer_info((CMSG_SIGNER_INFO *)buf, &signer); CryptMemFree(buf); } /* Getting the CMS signer info of a PKCS7 message is possible. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */), - "CryptMsgGetParam failed: %08x\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_CMS_SIGNER_INFO signer = { 0 }; signer.dwVersion = 1; signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; - U(signer.SignerId).IssuerSerialNumber.Issuer.cbData = - sizeof(encodedCommonName); - U(signer.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonName; - U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData = - sizeof(serialNum); - U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum; + signer.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonName); + signer.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonName; + signer.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum); + signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = serialNum; signer.HashAlgorithm.pszObjId = oid_rsa_md5; CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, buf, &size); compare_cms_signer_info((CMSG_CMS_SIGNER_INFO *)buf, &signer); @@ -2983,27 +2831,27 @@ static void test_decode_msg_get_param(void) /* index is ignored when getting signer count */ size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 1, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 1, "Expected 1 signer, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 1, "Expected 1 signer, got %ld\n", value); ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 0, "Expected 0 certs, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 0, "Expected 0 certs, got %ld\n", value); ret = CryptMsgGetParam(msg, CMSG_CRL_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 0, "Expected 0 CRLs, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 0, "Expected 0 CRLs, got %ld\n", value); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent, sizeof(signedWithCertAndCrlBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 1, "Expected 1 cert, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 1, "Expected 1 cert, got %ld\n", value); check_param("cert", msg, CMSG_CERT_PARAM, cert, sizeof(cert)); ret = CryptMsgGetParam(msg, CMSG_CRL_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 1, "Expected 1 CRL, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 1, "Expected 1 CRL, got %ld\n", value); check_param("crl", msg, CMSG_CRL_PARAM, crl, sizeof(crl)); check_param("signed with cert and CRL computed hash", msg, CMSG_COMPUTED_HASH_PARAM, signedWithCertAndCrlComputedHash, @@ -3013,27 +2861,18 @@ static void test_decode_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); ret = CryptMsgUpdate(msg, signedKeyIdEmptyContent, sizeof(signedKeyIdEmptyContent), TRUE); - if (!ret && GetLastError() == OSS_DATA_ERROR) - { - CryptMsgClose(msg); - win_skip("Subsequent tests crash on some Win9x\n"); - return; - } - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 0, &value, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(value == 1, "Expected 1 signer, got %d\n", value); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(value == 1, "Expected 1 signer, got %ld\n", value); /* Getting the regular (non-CMS) signer info from a CMS message is also * possible.. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_SIGNER_INFO signer; @@ -3056,19 +2895,16 @@ static void test_decode_msg_get_param(void) } size = 0; ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - if (ret) - buf = CryptMemAlloc(size); - else - buf = NULL; + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + buf = CryptMemAlloc(size); if (buf) { CMSG_CMS_SIGNER_INFO signer = { 0 }; signer.dwVersion = CMSG_SIGNED_DATA_V3; signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER; - U(signer.SignerId).KeyId.cbData = sizeof(serialNum); - U(signer.SignerId).KeyId.pbData = serialNum; + signer.SignerId.KeyId.cbData = sizeof(serialNum); + signer.SignerId.KeyId.pbData = serialNum; signer.HashAlgorithm.pszObjId = oid_rsa_md5; CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, buf, &size); compare_cms_signer_info((CMSG_CMS_SIGNER_INFO *)buf, &signer); @@ -3090,35 +2926,28 @@ static void test_decode_msg_get_param(void) check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, NULL, 0); CryptMsgClose(msg); - pCryptAcquireContextA(&hCryptProv, NULL, MS_ENHANCED_PROV_A, PROV_RSA_FULL, + CryptAcquireContextA(&hCryptProv, NULL, MS_ENHANCED_PROV_A, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); SetLastError(0xdeadbeef); ret = CryptImportKey(hCryptProv, publicPrivateKeyPair, sizeof(publicPrivateKeyPair), 0, 0, &key); - ok(ret || - broken(!ret && GetLastError() == NTE_PERM), /* WinME and some NT4 */ - "CryptImportKey failed: %08x\n", GetLastError()); + ok(ret, "CryptImportKey failed: %08lx\n", GetLastError()); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); CryptMsgUpdate(msg, envelopedMessage, sizeof(envelopedMessage), TRUE); check_param("enveloped message before decrypting", msg, CMSG_CONTENT_PARAM, envelopedMessage + sizeof(envelopedMessage) - 4, 4); - if (key) - { - decryptPara.hCryptProv = hCryptProv; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(ret, "CryptMsgControl failed: %08x\n", GetLastError()); - decryptPara.hCryptProv = 0; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(!ret && GetLastError() == CRYPT_E_ALREADY_DECRYPTED, - "expected CRYPT_E_ALREADY_DECRYPTED, got %08x\n", GetLastError()); - check_param("enveloped message", msg, CMSG_CONTENT_PARAM, msgData, - sizeof(msgData)); - } - else - win_skip("failed to import a key, skipping tests\n"); + + decryptPara.hCryptProv = hCryptProv; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); + decryptPara.hCryptProv = 0; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(!ret && GetLastError() == CRYPT_E_ALREADY_DECRYPTED, + "expected CRYPT_E_ALREADY_DECRYPTED, got %08lx\n", GetLastError()); + check_param("enveloped message", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -3128,17 +2957,12 @@ static void test_decode_msg_get_param(void) check_param("enveloped bare message before decrypting", msg, CMSG_CONTENT_PARAM, envelopedBareMessage + sizeof(envelopedBareMessage) - 4, 4); - if (key) - { - decryptPara.hCryptProv = hCryptProv; - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(ret, "CryptMsgControl failed: %08x\n", GetLastError()); - check_param("enveloped bare message", msg, CMSG_CONTENT_PARAM, msgData, - sizeof(msgData)); - } - else - win_skip("failed to import a key, skipping tests\n"); + + decryptPara.hCryptProv = hCryptProv; + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); + check_param("enveloped bare message", msg, CMSG_CONTENT_PARAM, msgData, sizeof(msgData)); CryptMsgClose(msg); if (key) @@ -3155,12 +2979,12 @@ static void test_decode_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 3, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "expected CRYPT_E_INVALID_INDEX, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_INDEX, got %08lx\n", GetLastError()); size = 0; SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 2, NULL, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size >= 142, "unexpected size: %u\n", size); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(size >= 142, "unexpected size: %lu\n", size); if (ret) buf = CryptMemAlloc(size); else @@ -3171,13 +2995,13 @@ static void test_decode_msg_get_param(void) SetLastError(0xdeadbeef); ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 2, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); ok(certInfo->SerialNumber.cbData == sizeof(serialNumber), - "unexpected serial number size: %u\n", certInfo->SerialNumber.cbData); + "unexpected serial number size: %lu\n", certInfo->SerialNumber.cbData); ok(!memcmp(certInfo->SerialNumber.pbData, serialNumber, sizeof(serialNumber)), "unexpected serial number\n"); ok(certInfo->Issuer.cbData == sizeof(issuer), - "unexpected issuer size: %u\n", certInfo->Issuer.cbData); + "unexpected issuer size: %lu\n", certInfo->Issuer.cbData); ok(!memcmp(certInfo->Issuer.pbData, issuer, sizeof(issuer)), "unexpected issuer\n"); CryptMemFree(buf); @@ -3221,22 +3045,22 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); /* either with no prior update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } CryptMsgClose(msg); @@ -3246,22 +3070,22 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); /* either with no prior update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } CryptMsgClose(msg); @@ -3270,22 +3094,22 @@ static void test_msg_control(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); /* either before an update.. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* or after an update. */ - for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + for (i = 1; i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO; i++) { SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, i, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); } CryptMsgClose(msg); @@ -3295,60 +3119,54 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, - "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_CONTROL_TYPE, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 1, 0, NULL); ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, - "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_CONTROL_TYPE, got %08lx\n", GetLastError()); /* Can't verify the hash of an indeterminate-type message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* Crashes ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, NULL); */ /* Can't decrypt an indeterminate-type message */ ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); + CryptMsgClose(msg); + + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); + /* Can't verify the hash of an empty message */ + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Crashes + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL); + */ + /* Can't verify the signature of a hash message */ + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); + CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), TRUE); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); + ok(!ret, "Expected failure\n"); CryptMsgClose(msg); - if (!old_crypt32) - { - msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, - NULL); - /* Can't verify the hash of an empty message */ - SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - todo_wine - ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, - "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - /* Crashes - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL); - */ - /* Can't verify the signature of a hash message */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); - CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), - TRUE); - /* Oddly enough, this fails, crashes on some Win9x */ - ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - ok(!ret, "Expected failure\n"); - CryptMsgClose(msg); - } msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - ok(ret, "CryptMsgControl failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); /* Can't decrypt an indeterminate-type message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0, @@ -3357,29 +3175,26 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* Still can't verify the hash of a detached message with the content * of the detached hash given.. */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE, - "Expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError()); + "Expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError()); /* and giving the content of the message after attempting to verify the * hash fails. */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); todo_wine - ok(!ret && - (GetLastError() == NTE_BAD_HASH_STATE || - GetLastError() == NTE_BAD_ALGID || /* Win9x */ - GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, " - "got %08x\n", GetLastError()); + "got %08lx\n", GetLastError()); CryptMsgClose(msg); /* Finally, verifying the hash of a detached message in the correct order: @@ -3392,12 +3207,12 @@ static void test_msg_control(void) NULL, NULL); ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - ok(ret, "CryptMsgControl failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, @@ -3406,12 +3221,12 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* Can't decrypt a signed message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); /* Crash ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); @@ -3423,10 +3238,8 @@ static void test_msg_control(void) */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == CRYPT_E_SIGNER_NOT_FOUND || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_SIGNER_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", - GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_SIGNER_NOT_FOUND, + "Expected CRYPT_E_SIGNER_NOT_FOUND, got %08lx\n", GetLastError()); /* The cert info is expected to have an issuer, serial number, and public * key info set. */ @@ -3436,9 +3249,8 @@ static void test_msg_control(void) certInfo.Issuer.pbData = encodedCommonName; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "Expected CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); CryptMsgClose(msg); /* This cert has a public key, but it's not in a usable form */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, @@ -3447,14 +3259,13 @@ static void test_msg_control(void) sizeof(signedWithCertWithPubKeyBareContent), TRUE); if (ret) { - /* Crashes on some Win9x */ /* Again, cert info needs to have a public key set */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD || GetLastError() == TRUST_E_NOSIGNATURE /* Vista */), - "Expected CRYPT_E_ASN1_EOD or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError()); + "Expected CRYPT_E_ASN1_EOD or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError()); /* The public key is supposed to be in encoded form.. */ certInfo.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa; certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey); @@ -3464,7 +3275,7 @@ static void test_msg_control(void) ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || GetLastError() == TRUST_E_NOSIGNATURE /* Vista */), - "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError()); + "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError()); /* but not as a X509_PUBLIC_KEY_INFO.. */ certInfo.SubjectPublicKeyInfo.Algorithm.pszObjId = NULL; certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(encodedPubKey); @@ -3474,7 +3285,7 @@ static void test_msg_control(void) ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG || GetLastError() == TRUST_E_NOSIGNATURE /* Vista */), - "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError()); + "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError()); /* This decodes successfully, but it doesn't match any key in the message */ certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(mod_encoded); certInfo.SubjectPublicKeyInfo.PublicKey.pbData = mod_encoded; @@ -3488,7 +3299,7 @@ static void test_msg_control(void) ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE || GetLastError() == TRUST_E_NOSIGNATURE /* Vista */), - "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError()); + "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError()); } CryptMsgClose(msg); /* A message with no data doesn't have a valid signature */ @@ -3501,12 +3312,11 @@ static void test_msg_control(void) certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(pubKey); certInfo.SubjectPublicKeyInfo.PublicKey.pbData = pubKey; SetLastError(0xdeadbeef); - /* Crashes on some Win9x */ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE || GetLastError() == TRUST_E_NOSIGNATURE /* Vista */), - "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError()); + "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError()); } CryptMsgClose(msg); /* Finally, this succeeds */ @@ -3514,8 +3324,7 @@ static void test_msg_control(void) CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), TRUE); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgControl failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); CryptMsgClose(msg); /* Test verifying signature of a detached signed message */ @@ -3523,25 +3332,19 @@ static void test_msg_control(void) NULL, NULL); ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); /* Can't verify the sig without having updated the data */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE || - GetLastError() == OSS_DATA_ERROR /* Win9x */), - "expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n", + ok(!ret && GetLastError() == NTE_BAD_SIGNATURE, + "expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError()); /* Now that the signature's been checked, can't do the final update */ SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); todo_wine - ok((!ret && - (GetLastError() == NTE_BAD_HASH_STATE || - GetLastError() == NTE_BAD_ALGID || /* Win9x */ - GetLastError() == CRYPT_E_MSG_ERROR)) || /* Vista */ - broken(ret), /* Win9x */ - "expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, " - "got %08x\n", GetLastError()); + ok(!ret && (GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */ + "expected NTE_BAD_HASH_STATE or CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError()); CryptMsgClose(msg); /* Updating with the detached portion of the message and the data of the * the message allows the sig to be verified. @@ -3550,12 +3353,11 @@ static void test_msg_control(void) NULL, NULL); ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgControl failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -3564,23 +3366,22 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); decryptPara.cbSize = sizeof(decryptPara); - if (!old_crypt32) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); - } + + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); + SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedEmptyBareContent, sizeof(envelopedEmptyBareContent), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "expected CRYPT_E_INVALID_INDEX, got %08x\n", GetLastError()); + "expected CRYPT_E_INVALID_INDEX, got %08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -3588,50 +3389,14 @@ static void test_msg_control(void) SetLastError(0xdeadbeef); ret = CryptMsgUpdate(msg, envelopedBareMessage, sizeof(envelopedBareMessage), TRUE); - ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); CryptMsgClose(msg); } -/* win9x has much less parameter checks and will crash on many tests - * this code is from test_signed_msg_update() - */ -static BOOL detect_nt(void) -{ - BOOL ret; - CMSG_SIGNER_ENCODE_INFO signer = { sizeof(signer), 0 }; - CERT_INFO certInfo = { 0 }; - - if (!pCryptAcquireContextW) - return FALSE; - - certInfo.SerialNumber.cbData = sizeof(serialNum); - certInfo.SerialNumber.pbData = serialNum; - certInfo.Issuer.cbData = sizeof(encodedCommonName); - certInfo.Issuer.pbData = encodedCommonName; - signer.pCertInfo = &certInfo; - signer.HashAlgorithm.pszObjId = oid_rsa_md5; - - ret = pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, - PROV_RSA_FULL, CRYPT_NEWKEYSET); - if (!ret && GetLastError() == NTE_EXISTS) { - ret = pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, - PROV_RSA_FULL, 0); - } - - if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) return FALSE; - - /* cleanup */ - CryptReleaseContext(signer.hCryptProv, 0); - pCryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, - CRYPT_DELETEKEYSET); - - return TRUE; -} - static void test_msg_get_and_verify_signer(void) { BOOL ret; @@ -3652,21 +3417,21 @@ static void test_msg_get_and_verify_signer(void) SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); /* The signer is cleared on error */ signer = (PCCERT_CONTEXT)0xdeadbeef; SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); ok(!signer, "expected signer to be NULL\n"); /* The signer index is also cleared on error */ signerIndex = 0xdeadbeef; SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); - ok(!signerIndex, "expected 0, got %d\n", signerIndex); + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); + ok(!signerIndex, "expected 0, got %ld\n", signerIndex); /* An unsigned message (msgData isn't a signed message at all) * likewise has no signer. */ @@ -3674,7 +3439,7 @@ static void test_msg_get_and_verify_signer(void) SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); @@ -3682,10 +3447,9 @@ static void test_msg_get_and_verify_signer(void) ret = CryptMsgUpdate(msg, signedEmptyContent, sizeof(signedEmptyContent), TRUE); if (ret) { - /* Crashes on most Win9x */ ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); } CryptMsgClose(msg); @@ -3694,20 +3458,17 @@ static void test_msg_get_and_verify_signer(void) CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent, sizeof(signedWithCertWithValidPubKeyContent), TRUE); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); /* the signer index can be retrieved, .. */ signerIndex = 0xdeadbeef; ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); if (ret) - ok(signerIndex == 0, "expected 0, got %d\n", signerIndex); + ok(signerIndex == 0, "expected 0, got %ld\n", signerIndex); /* as can the signer cert. */ signer = (PCCERT_CONTEXT)0xdeadbeef; ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); if (ret) ok(signer != NULL && signer != (PCCERT_CONTEXT)0xdeadbeef, "expected a valid signer\n"); @@ -3720,16 +3481,15 @@ static void test_msg_get_and_verify_signer(void) ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, CMSG_USE_SIGNER_INDEX_FLAG, NULL, &signerIndex); ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX, - "expected CRYPT_E_INVALID_INDEX, got 0x%08x\n", GetLastError()); + "expected CRYPT_E_INVALID_INDEX, got 0x%08lx\n", GetLastError()); /* Specifying CMSG_TRUSTED_SIGNER_FLAG and no cert stores causes the * message signer not to be found. */ SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER || - broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)), - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); /* Specifying CMSG_TRUSTED_SIGNER_FLAG and an empty cert store also causes * the message signer not to be found. */ @@ -3738,40 +3498,168 @@ static void test_msg_get_and_verify_signer(void) SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER || - broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)), - "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError()); + ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER, + "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win98 */), - "CertAddEncodedCertificateToStore failed: 0x%08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: 0x%08lx\n", GetLastError()); /* Specifying CMSG_TRUSTED_SIGNER_FLAG with a cert store that contains * the signer succeeds. */ SetLastError(0xdeadbeef); ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG, NULL, NULL); - ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */), - "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError()); + ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError()); + CertCloseStore(store, 0); + CryptMsgClose(msg); +} + +/* Generated with: + * openssl ecparam -name prime256v1 -genkey -out private-key.pem + * openssl req -new -x509 -key private-key.pem -out certificate.der -outform der -days 10000 -subj "/C=US/ST=T/L=T/O=T/CN=T" + * openssl pkcs12 -export -out certificate.pfx -inkey private-key.pem -in certificate.der + * - import certificate.pfx on Windows + * signtool /sign /v /fd SHA256 certificate.pfx a.exe + * - extract signed message from a.exe + */ +static const BYTE msg_signed_ecc_prime256v1[] = { +0x30,0x82,0x03,0x85,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0, +0x82,0x03,0x76,0x30,0x82,0x03,0x72,0x02,0x01,0x01,0x31,0x0f,0x30,0x0d,0x06,0x09, +0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x30,0x5c,0x06,0x0a,0x2b, +0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,0xa0,0x4e,0x30,0x4c,0x30,0x17,0x06, +0x0a,0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0f,0x30,0x09,0x03,0x01,0x00, +0xa0,0x04,0xa2,0x02,0x80,0x00,0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01, +0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20,0x32,0x54,0x6a,0x85,0xd7,0xe6,0x83, +0x46,0x6c,0x94,0x58,0x3b,0x17,0xa4,0xa8,0x8b,0xea,0xea,0x11,0xe0,0x6e,0xc4,0x3c, +0xea,0xde,0xbb,0x2e,0x7d,0xa3,0xb6,0xbe,0x69,0xa0,0x82,0x01,0xd5,0x30,0x82,0x01, +0xd1,0x30,0x82,0x01,0x77,0xa0,0x03,0x02,0x01,0x02,0x02,0x14,0x13,0x09,0x38,0x76, +0x3a,0x38,0xef,0x36,0xac,0xc3,0xa5,0x7e,0xa5,0xad,0x56,0x50,0x8d,0x77,0x55,0x2c, +0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x3d,0x31,0x0b, +0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0a,0x30,0x08,0x06, +0x03,0x55,0x04,0x08,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x07, +0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x0a,0x0c,0x01,0x54,0x31, +0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x0c,0x01,0x54,0x30,0x20,0x17,0x0d,0x32, +0x33,0x30,0x36,0x32,0x39,0x30,0x33,0x31,0x38,0x35,0x35,0x5a,0x18,0x0f,0x32,0x30, +0x35,0x30,0x31,0x31,0x31,0x34,0x30,0x33,0x31,0x38,0x35,0x35,0x5a,0x30,0x3d,0x31, +0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0a,0x30,0x08, +0x06,0x03,0x55,0x04,0x08,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04, +0x07,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x0a,0x0c,0x01,0x54, +0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x0c,0x01,0x54,0x30,0x59,0x30,0x13, +0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d, +0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xfe,0xdb,0x26,0x60,0xf6,0x89,0x3d,0xa4,0x50, +0x1f,0x06,0x91,0x4e,0x07,0x86,0x70,0x2b,0xc0,0x7c,0x5e,0xb3,0xca,0xdc,0x1a,0x8b, +0x82,0xdd,0x41,0x8a,0x62,0x0f,0xba,0xd1,0xd7,0x80,0xc8,0x20,0x77,0xba,0xe7,0xe1, +0x36,0xf8,0x76,0x9a,0x54,0x6a,0x1b,0x67,0x45,0x3b,0xd7,0x85,0x84,0xbe,0x11,0xe6, +0x6c,0x70,0xd8,0x18,0x68,0xd8,0xa7,0xa3,0x53,0x30,0x51,0x30,0x1d,0x06,0x03,0x55, +0x1d,0x0e,0x04,0x16,0x04,0x14,0x94,0x15,0x14,0xad,0x7e,0xaf,0x63,0xa4,0x12,0x29, +0xaa,0xe4,0x26,0x54,0x7b,0x4e,0x2c,0xb9,0xdb,0xc8,0x30,0x1f,0x06,0x03,0x55,0x1d, +0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x94,0x15,0x14,0xad,0x7e,0xaf,0x63,0xa4,0x12, +0x29,0xaa,0xe4,0x26,0x54,0x7b,0x4e,0x2c,0xb9,0xdb,0xc8,0x30,0x0f,0x06,0x03,0x55, +0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x0a,0x06,0x08, +0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x03,0x48,0x00,0x30,0x45,0x02,0x21,0x00, +0xe6,0xb6,0x11,0x8d,0x75,0x3a,0x62,0xf3,0x08,0x17,0xce,0xa5,0x5a,0xcb,0x61,0xc7, +0x0a,0x33,0xdb,0x30,0x29,0x6b,0x5e,0xac,0xfc,0xaa,0xed,0x14,0xd1,0xd7,0xae,0x24, +0x02,0x20,0x2e,0x4d,0x70,0xc7,0x26,0xf7,0xea,0xa3,0x07,0x8a,0x6f,0x98,0x07,0xe1, +0xbc,0x38,0x13,0x88,0x17,0xdd,0x01,0x21,0x1e,0xb0,0xbb,0x32,0xfc,0x7a,0xc0,0xd5, +0x80,0x45,0x31,0x82,0x01,0x23,0x30,0x82,0x01,0x1f,0x02,0x01,0x01,0x30,0x55,0x30, +0x3d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0a, +0x30,0x08,0x06,0x03,0x55,0x04,0x08,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03, +0x55,0x04,0x07,0x0c,0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x0a,0x0c, +0x01,0x54,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x0c,0x01,0x54,0x02,0x14, +0x13,0x09,0x38,0x76,0x3a,0x38,0xef,0x36,0xac,0xc3,0xa5,0x7e,0xa5,0xad,0x56,0x50, +0x8d,0x77,0x55,0x2c,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02, +0x01,0x05,0x00,0xa0,0x5e,0x30,0x10,0x06,0x0a,0x2b,0x06,0x01,0x04,0x01,0x82,0x37, +0x02,0x01,0x0c,0x31,0x02,0x30,0x00,0x30,0x19,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7, +0x0d,0x01,0x09,0x03,0x31,0x0c,0x06,0x0a,0x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x02, +0x01,0x04,0x30,0x2f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x04,0x31, +0x22,0x04,0x20,0x25,0xc1,0x32,0xc0,0x4f,0x1a,0xae,0x84,0xd2,0x6a,0xff,0x0e,0xc9, +0xe8,0x85,0xbc,0x38,0x63,0x7b,0x22,0x89,0x1c,0x97,0x29,0xc2,0x8f,0x70,0x40,0xc2, +0xdf,0x42,0x9a,0x30,0x0b,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,0x05,0x00, +0x04,0x47,0x30,0x45,0x02,0x20,0x07,0x66,0x32,0x9a,0x15,0x8f,0x39,0x0a,0xb0,0xe1, +0x80,0xc9,0x82,0x23,0xb8,0x99,0x54,0x4c,0xa7,0x65,0xf2,0x99,0x11,0x70,0x1e,0xdf, +0xf5,0x40,0x73,0x7a,0x8d,0xd1,0x02,0x21,0x00,0x84,0xe0,0xec,0x38,0x33,0x01,0x28, +0x2b,0x4b,0x72,0xed,0x6a,0x64,0xb7,0xaf,0x7a,0x34,0x4b,0x6b,0x69,0xf6,0x55,0x9a, +0x8e,0x0d,0xe9,0xc1,0x85,0x80,0x4d,0xef,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; + +static void test_verify_ecc_signature(void) +{ + HCERTSTORE store; + HCRYPTKEY key; +#ifndef __REACTOS__ + BCRYPT_KEY_HANDLE bkey; +#endif + HCRYPTMSG msg; + BOOL bret; + CERT_INFO *cert_info; + PCCERT_CONTEXT cert; + DWORD size; + CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA verify_para = { sizeof(verify_para) }; + HCRYPTOIDFUNCSET set; + void *import_func; + HCRYPTOIDFUNCADDR hfunc = NULL; + CMSG_CMS_SIGNER_INFO *signer_info; + + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + ok(!!msg, "failed, error %#lx.\n", GetLastError()); + bret = CryptMsgUpdate(msg, msg_signed_ecc_prime256v1, sizeof(msg_signed_ecc_prime256v1), TRUE); + ok(bret, "failed, error %#lx.\n", GetLastError()); + store = CertOpenStore(CERT_STORE_PROV_MSG, X509_ASN_ENCODING, 0, 0, msg); + ok(!!store, "failed, error %#lx.\n", GetLastError()); + size = 0; + bret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_INFO_PARAM, 0, NULL, &size); + ok(bret, "failed, error %#lx.\n", GetLastError()); + cert_info = malloc(size); + bret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_INFO_PARAM, 0, cert_info, &size); + ok(bret, "failed, error %#lx.\n", GetLastError()); + cert = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING, cert_info); + ok(!!cert, "failed, error %#lx.\n", GetLastError()); + + ok(!strcmp(cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY), + "got OID %s.\n", cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId); + size = 0; + bret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size); + ok(bret, "failed, error %#lx.\n", GetLastError()); + signer_info = malloc(size); + bret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, signer_info, &size); + ok(bret, "failed, error %#lx.\n", GetLastError()); + ok(!strcmp(signer_info->HashAlgorithm.pszObjId, szOID_NIST_sha256), "got %s.\n", + signer_info->HashAlgorithm.pszObjId); + ok(!strcmp(signer_info->HashEncryptionAlgorithm.pszObjId, szOID_ECC_PUBLIC_KEY), "got %s.\n", + signer_info->HashEncryptionAlgorithm.pszObjId); + + set = CryptInitOIDFunctionSet(CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC, 0); + ok(!!set, "failed, error %#lx.\n", GetLastError()); + bret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId, + 0, (void **)&import_func, &hfunc); + ok(!bret, "succeeded.\n"); + + bret = CryptImportPublicKeyInfo(0, X509_ASN_ENCODING, &cert->pCertInfo->SubjectPublicKeyInfo, &key); + ok(!bret && GetLastError() == CRYPT_E_ASN1_BADTAG, "got ret %d, error %#lx.\n", bret, GetLastError()); + +#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptImportPublicKeyInfoEx2 + bret = CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING, &cert->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &bkey); + ok(bret, "failed, error %#lx.\n", GetLastError()); + BCryptDestroyKey(bkey); +#endif + + bret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, cert->pCertInfo); + ok(bret, "failed, error %#lx.\n", GetLastError()); + + verify_para.dwSignerType = CMSG_VERIFY_SIGNER_CERT; + verify_para.pvSigner = (void *)cert; + bret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE_EX, &verify_para); + ok(bret, "failed, error %#lx.\n", GetLastError()); + + free(signer_info); + free(cert_info); + CertFreeCertificateContext(cert); CertCloseStore(store, 0); CryptMsgClose(msg); } START_TEST(msg) { - init_function_pointers(); - have_nt = detect_nt(); - if (!have_nt) - win_skip("Win9x crashes on some parameter checks\n"); - - /* I_CertUpdateStore can be used for verification if crypt32 is new enough */ - if (!GetProcAddress(GetModuleHandleA("crypt32.dll"), "I_CertUpdateStore")) - { - win_skip("Some tests will crash on older crypt32 implementations\n"); - old_crypt32 = TRUE; - } - /* Basic parameter checking tests */ test_msg_open_to_encode(); test_msg_open_to_decode(); @@ -3787,4 +3675,5 @@ START_TEST(msg) test_decode_msg(); test_msg_get_and_verify_signer(); + test_verify_ecc_signature(); } diff --git a/modules/rostests/winetests/crypt32/object.c b/modules/rostests/winetests/crypt32/object.c index 211b5423e01..22936d3738d 100644 --- a/modules/rostests/winetests/crypt32/object.c +++ b/modules/rostests/winetests/crypt32/object.c @@ -26,9 +26,6 @@ #include "wine/test.h" -static BOOL (WINAPI * pCryptQueryObject)(DWORD, const void *, DWORD, DWORD, - DWORD, DWORD *, DWORD *, DWORD *, HCERTSTORE *, HCRYPTMSG *, const void **); - static BYTE bigCert[] = { 0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31, 0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75, @@ -45,18 +42,10 @@ static char bigCertBase64[] = "MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEwMDAw\n" "MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n" "AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n"; -static WCHAR bigCertBase64W[] = { -'M','H','o','C','A','Q','E','w','A','g','Y','A','M','B','U','x','E','z','A', -'R','B','g','N','V','B','A','M','T','C','k','p','1','Y','W','4','g','T','G', -'F','u','Z','w','A','w','I','h','g','P','M','T','Y','w','M','T','A','x','M', -'D','E','w',',','D','A','w','\n', -'M','D','B','a','G','A','8','x','N','j','A','x','M','D','E','w','M','T','A', -'w','M','D','A','w','M','F','o','w','F','T','E','T','M','B','E','G','A','1', -'U','E','A','x','M','K','S','n','V','h','b','i','B','M','Y','W','5','n','A', -'D','A','H','M','A','I','G','\n', -'A','A','M','B','A','K','M','W','M','B','Q','w','E','g','Y','D','V','R','0', -'T','A','Q','H','/','B','A','g','w','B','g','E','B','/','w','I','B','A','Q', -'=','=','\n',0 }; +static WCHAR bigCertBase64W[] = +L"MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEw,DAw\n" +"MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n" +"AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n"; static BYTE signedWithCertWithValidPubKeyContent[] = { 0x30,0x82,0x01,0x89,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02, 0xa0,0x82,0x01,0x7a,0x30,0x82,0x01,0x76,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c, @@ -95,88 +84,190 @@ static char signedWithCertWithValidPubKeyContentBase64[] = "EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw" "s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g" "7pMZOVHkRLgLKPSoDQ=="; -static WCHAR signedWithCertWithValidPubKeyContentBase64W[] = { -'M','I','I','B','i','Q','Y','J','K','o','Z','I','h','v','c','N','A','Q','c','C', -'o','I','I','B','e','j','C','C','A','X','Y','C','A','Q','E','x','D','j','A','M', -'B','g','g','q','h','k','i','G','9','w','0','C','B','Q','U','A','M','B','M','G', -'C','S','q','G','S','I','b','3','D','Q','E','H','A','a','A','G','B','A','Q','B', -'A','g','M','E','o','I','H','S','M','I','H','P','A','g','E','B','M','A','I','G', -'A','D','A','V','M','R','M','w','E','Q','Y','D','V','Q','Q','D','E','w','p','K', -'d','W','F','u','I','E','x','h','b','m','c','A','M','C','I','Y','D','z','E','2', -'M','D','E','w','M','T','A','x','M','D','A','w','M','D','A','w','W','h','g','P', -'M','T','Y','w','M','T','A','x','M','D','E','w','M','D','A','w','M','D','B','a', -'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1', -'Y','W','4','g','T','G','F','u','Z','w','A','w','X','D','A','N','B','g','k','q', -'h','k','i','G','9','w','0','B','A','Q','E','F','A','A','N','L','A','D','B','I', -'A','k','E','A','4','l','Q','6','p','4','O','x','J','x','Q','+','W','b','u','0', -'U','+','Y','f','5','1','3','x','I','W','i','t','h','V','P','b','a','x','7','r', -'Z','Z','c','D','h','m','D','e','8','2','w','4','d','e','B','M','Y','b','u','8', -'Y','h','e','p','z','X','k','/','I','U','6','W','y','w','7','c','Y','Z','Q','w', -'G','B','B','r','0','B','w','Q','e','Q','I','D','A','Q','A','B','o','x','Y','w', -'F','D','A','S','B','g','N','V','H','R','M','B','A','f','8','E','C','D','A','G', -'A','Q','H','/','A','g','E','B','M','X','c','w','d','Q','I','B','A','T','A','a', -'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1', -'Y','W','4','g','T','G','F','u','Z','w','A','C','A','Q','E','w','D','A','Y','I', -'K','o','Z','I','h','v','c','N','A','g','U','F','A','D','A','E','B','g','A','F', -'A','A','R','A','g','a','Z','w','s','+','9','Z','0','W','b','R','m','8','C','a', -'t','p','p','e','b','W','9','t','D','V','m','p','q','m','7','p','L','K','A','e', -'7','s','J','g','v','F','m','+','P','2','M','G','j','c','k','R','H','S','N','k', -'k','u','8','u','/','F','c','p','p','K','/','g','7','p','M','Z','O','V','H','k', -'R','L','g','L','K','P','S','o','D','Q','=','=',0 }; +static WCHAR signedWithCertWithValidPubKeyContentBase64W[] = +L"MIIBiQYJKoZIhvcNAQcCoIIBejCCAXYCAQExDjAMBggqhkiG9w0CBQUAMBMGCSqG" +"SIb3DQEHAaAGBAQBAgMEoIHSMIHPAgEBMAIGADAVMRMwEQYDVQQDEwpKdWFuIExh" +"bmcAMCIYDzE2MDEwMTAxMDAwMDAwWhgPMTYwMTAxMDEwMDAwMDBaMBUxEzARBgNV" +"BAMTCkp1YW4gTGFuZwAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA4lQ6p4OxJxQ+" +"Wbu0U+Yf513xIWithVPbax7rZZcDhmDe82w4deBMYbu8YhepzXk/IU6Wyw7cYZQw" +"GBBr0BwQeQIDAQABoxYwFDASBgNVHRMBAf8ECDAGAQH/AgEBMXcwdQIBATAaMBUx" +"EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw" +"s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g" +"7pMZOVHkRLgLKPSoDQ=="; + +/* Self-signed .exe, built with tcc, signed with signtool + * (and a certificate generated on a self-signed CA). + * + * small.c: + * int _start() + * { + * return 0; + * } + * + * tcc -nostdlib small.c + * signtool sign /v /f codesign.pfx small.exe + */ +static const BYTE signed_pe_blob[] = +{ + 0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD, + 0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F, + 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A, + 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x4C,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xE0,0x00,0x0F,0x03,0x0B,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00, + 0xE7,0x0C,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x68,0x05,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00, + 0x18,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x89,0xE5,0x81,0xEC,0x00,0x00,0x00,0x00,0x90,0xB8,0x00,0x00,0x00,0x00,0xE9, + 0x00,0x00,0x00,0x00,0xC9,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00, + /* Start of the signature overlay */ + 0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02, + 0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01, + 0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30, + 0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04, + 0x14,0xA0,0x95,0xDE,0xBD,0x1A,0xB7,0x86,0xAF,0x50,0x63,0xD8,0x8F,0x90,0xD5,0x49,0x96,0x4E,0x44,0xF0,0x71,0xA0,0x82,0x03, + 0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87, + 0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30, + 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74, + 0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33, + 0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64, + 0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, + 0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC, + 0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C, + 0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05, + 0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5, + 0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A, + 0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E, + 0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51, + 0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80, + 0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0, + 0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95, + 0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A, + 0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55, + 0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04, + 0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30, + 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74, + 0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86, + 0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20, + 0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB, + 0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5, + 0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD, + 0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC, + 0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0, + 0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04, + 0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67, + 0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74, + 0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C, + 0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6, + 0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30, + 0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53, + 0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05, + 0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06, + 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04, + 0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04, + 0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x3D, + 0x08,0xC8,0xA3,0xEE,0x05,0x1A,0x61,0xD9,0xFE,0x1A,0x63,0xC0,0x8A,0x6E,0x9D,0xF9,0xC3,0x13,0x98,0x30,0x0D,0x06,0x09,0x2A, + 0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x90,0xF9,0xC0,0x7F,0x1D,0x70,0x8C,0x04,0x22,0x82, + 0xB6,0x2D,0x48,0xBF,0x30,0x51,0x29,0xF8,0xE3,0x11,0x39,0xE0,0x64,0x23,0x72,0xE2,0x4C,0x09,0x9F,0x39,0xF2,0x6F,0xDD,0xB9, + 0x5A,0x3D,0xEF,0xEB,0xBE,0xEC,0x3B,0xE6,0x58,0x4C,0xC9,0x4F,0xED,0xCB,0x6E,0x9D,0x67,0x8E,0x89,0x92,0x40,0x39,0xA2,0x5F, + 0xF9,0xEF,0xD3,0xF5,0x24,0x27,0x8D,0xF7,0x3C,0x92,0x66,0x56,0xC8,0x2B,0xEA,0x04,0xA1,0x0E,0xDA,0x89,0x30,0xA7,0x01,0xD8, + 0x0B,0xF8,0xFD,0x99,0xB6,0xC0,0x38,0xB0,0x21,0x50,0x3A,0x86,0x01,0xD0,0xF3,0x86,0x72,0xE3,0x5A,0xBB,0x2A,0x6E,0xBD,0xFB, + 0x22,0xF9,0x42,0xD3,0x04,0xFE,0x8D,0xD8,0x79,0xD1,0xEE,0x61,0xC6,0x48,0x04,0x99,0x9A,0xA2,0x73,0xE5,0xFB,0x24,0x10,0xD5, + 0x6B,0x71,0x80,0x0E,0x09,0xEA,0x85,0x9A,0xBD,0xBB,0xDE,0x99,0x5D,0xA3,0x18,0x4D,0xED,0x20,0x73,0x3E,0x32,0xEF,0x2C,0xAC, + 0x5A,0x83,0x87,0x1F,0x7F,0x19,0x61,0x35,0x53,0xC1,0xAA,0x89,0x97,0xB3,0xDD,0x8D,0xA8,0x67,0x5B,0xC2,0xE2,0x09,0xB7,0xDD, + 0x6A,0xCB,0xD5,0xBF,0xD6,0x08,0xE2,0x23,0x1A,0x41,0x9D,0xD5,0x6A,0x6B,0x8D,0x3C,0x29,0x1B,0xF1,0x3F,0x4E,0x4A,0x8F,0x29, + 0x33,0xF9,0x1C,0x60,0xA0,0x92,0x7E,0x4F,0x35,0xB8,0xDD,0xEB,0xD1,0x68,0x1A,0x9D,0xA2,0xA6,0x97,0x1F,0x5F,0xC6,0x2C,0xFB, + 0xCA,0xDF,0xF7,0x95,0x33,0x95,0xD4,0x79,0x5C,0x73,0x87,0x49,0x1F,0x8C,0x6E,0xCE,0x3E,0x6D,0x3D,0x2B,0x6B,0xD7,0x66,0xE9, + 0x88,0x6F,0xF2,0x83,0xB9,0x9B,0x00,0x00 +}; static void test_query_object(void) { + WCHAR tmp_path[MAX_PATH]; BOOL ret; CRYPT_DATA_BLOB blob; + DWORD content_type; /* Test the usual invalid arguments */ SetLastError(0xdeadbeef); - ret = pCryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, + ret = CryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with a simple cert */ blob.pbData = bigCert; blob.cbData = sizeof(bigCert); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); /* The same cert, base64-encoded */ blob.pbData = (BYTE *)bigCertBase64; blob.cbData = sizeof(bigCertBase64); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); /* The same base64-encoded cert, restricting the format types */ SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); /* The same cert, base64-encoded but as a wide character string */ blob.pbData = (BYTE *)bigCertBase64W; blob.cbData = sizeof(bigCertBase64W); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); /* For brevity, not tested here, but tested on Windows: same failure * (CRYPT_E_NO_MATCH) when the wide character base64-encoded cert * is written to a file and queried. @@ -185,51 +276,61 @@ static void test_query_object(void) blob.pbData = signedWithCertWithValidPubKeyContent; blob.cbData = sizeof(signedWithCertWithValidPubKeyContent); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64; blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); /* A valid signed message, encoded as a wide character base64 string, can * be queried successfully. */ blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64W; blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64W); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, - "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); + "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0, NULL, NULL, NULL, NULL, NULL, NULL); - ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); + + GetEnvironmentVariableW( L"TMP", tmp_path, MAX_PATH ); + SetEnvironmentVariableW(L"TMP", L"C:\\nonexistent"); + blob.pbData = (BYTE *)signed_pe_blob; + blob.cbData = sizeof(signed_pe_blob); + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &content_type, + NULL, NULL, NULL, NULL); + ok(!ret, "CryptQueryObject succeeded\n"); + ok(GetLastError() == CRYPT_E_NO_MATCH, "Unexpected error %lu.\n", GetLastError()); + SetEnvironmentVariableW(L"TMP", tmp_path); + + blob.pbData = (BYTE *)signed_pe_blob; + blob.cbData = sizeof(signed_pe_blob); + ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, + CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &content_type, + NULL, NULL, NULL, NULL); + ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError()); + ok(content_type == CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED, + "Got unexpected content_type %#lx.\n", content_type); } START_TEST(object) { - HMODULE mod = GetModuleHandleA("crypt32.dll"); - - pCryptQueryObject = (void *)GetProcAddress(mod, "CryptQueryObject"); - - if (!pCryptQueryObject) - { - win_skip("CryptQueryObject is not available\n"); - return; - } - test_query_object(); } diff --git a/modules/rostests/winetests/crypt32/oid.c b/modules/rostests/winetests/crypt32/oid.c index ae03bba90e8..6f88dfa9dc3 100644 --- a/modules/rostests/winetests/crypt32/oid.c +++ b/modules/rostests/winetests/crypt32/oid.c @@ -29,93 +29,86 @@ #include "wine/test.h" - -static BOOL (WINAPI *pCryptEnumOIDInfo)(DWORD,DWORD,void*,PFN_CRYPT_ENUM_OID_INFO); - - struct OIDToAlgID { LPCSTR oid; - LPCSTR altOid; DWORD algID; DWORD altAlgID; }; static const struct OIDToAlgID oidToAlgID[] = { - { szOID_RSA_RSA, NULL, CALG_RSA_KEYX }, - { szOID_RSA_MD2RSA, NULL, CALG_MD2 }, - { szOID_RSA_MD4RSA, NULL, CALG_MD4 }, - { szOID_RSA_MD5RSA, NULL, CALG_MD5 }, - { szOID_RSA_SHA1RSA, NULL, CALG_SHA }, - { szOID_RSA_DH, NULL, CALG_DH_SF }, - { szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM }, - { szOID_RSA_SMIMEalgCMS3DESwrap, NULL, CALG_3DES }, - { szOID_RSA_SMIMEalgCMSRC2wrap, NULL, CALG_RC2 }, - { szOID_RSA_MD2, NULL, CALG_MD2 }, - { szOID_RSA_MD4, NULL, CALG_MD4 }, - { szOID_RSA_MD5, NULL, CALG_MD5 }, - { szOID_RSA_RC2CBC, NULL, CALG_RC2 }, - { szOID_RSA_RC4, NULL, CALG_RC4 }, - { szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES }, - { szOID_ANSI_X942_DH, NULL, CALG_DH_SF }, - { szOID_X957_DSA, NULL, CALG_DSS_SIGN }, - { szOID_X957_SHA1DSA, NULL, CALG_SHA }, - { szOID_OIWSEC_md4RSA, NULL, CALG_MD4 }, - { szOID_OIWSEC_md5RSA, NULL, CALG_MD5 }, - { szOID_OIWSEC_md4RSA2, NULL, CALG_MD4 }, - { szOID_OIWSEC_desCBC, NULL, CALG_DES }, - { szOID_OIWSEC_dsa, NULL, CALG_DSS_SIGN }, - { szOID_OIWSEC_shaDSA, NULL, CALG_SHA }, - { szOID_OIWSEC_shaRSA, NULL, CALG_SHA }, - { szOID_OIWSEC_sha, NULL, CALG_SHA }, - { szOID_OIWSEC_rsaXchg, NULL, CALG_RSA_KEYX }, - { szOID_OIWSEC_sha1, NULL, CALG_SHA }, - { szOID_OIWSEC_dsaSHA1, NULL, CALG_SHA }, - { szOID_OIWSEC_sha1RSASign, NULL, CALG_SHA }, - { szOID_OIWDIR_md2RSA, NULL, CALG_MD2 }, - { szOID_INFOSEC_mosaicUpdatedSig, NULL, CALG_SHA }, - { szOID_INFOSEC_mosaicKMandUpdSig, NULL, CALG_DSS_SIGN }, - { szOID_NIST_sha256, NULL, CALG_SHA_256, -1 }, - { szOID_NIST_sha384, NULL, CALG_SHA_384, -1 }, - { szOID_NIST_sha512, NULL, CALG_SHA_512, -1 } + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_MD2RSA, CALG_MD2 }, + { szOID_RSA_MD4RSA, CALG_MD4 }, + { szOID_RSA_MD5RSA, CALG_MD5 }, + { szOID_RSA_SHA1RSA, CALG_SHA }, + { szOID_RSA_DH, CALG_DH_SF }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, + { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_X957_SHA1DSA, CALG_SHA }, + { szOID_OIWSEC_md4RSA, CALG_MD4 }, + { szOID_OIWSEC_md5RSA, CALG_MD5 }, + { szOID_OIWSEC_md4RSA2, CALG_MD4 }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, + { szOID_OIWSEC_shaDSA, CALG_SHA }, + { szOID_OIWSEC_shaRSA, CALG_SHA }, + { szOID_OIWSEC_sha, CALG_SHA }, + { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, + { szOID_OIWSEC_sha1, CALG_SHA }, + { szOID_OIWSEC_dsaSHA1, CALG_SHA }, + { szOID_OIWSEC_sha1RSASign, CALG_SHA }, + { szOID_OIWDIR_md2RSA, CALG_MD2 }, + { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, + { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, + { szOID_NIST_sha256, CALG_SHA_256, -1 }, + { szOID_NIST_sha384, CALG_SHA_384, -1 }, + { szOID_NIST_sha512, CALG_SHA_512, -1 }, + { szOID_ECC_PUBLIC_KEY, CALG_OID_INFO_PARAMETERS }, }; static const struct OIDToAlgID algIDToOID[] = { - { szOID_RSA_RSA, NULL, CALG_RSA_KEYX }, - { szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM }, - { szOID_RSA_MD2, NULL, CALG_MD2 }, - { szOID_RSA_MD4, NULL, CALG_MD4 }, - { szOID_RSA_MD5, NULL, CALG_MD5 }, - { szOID_RSA_RC2CBC, NULL, CALG_RC2 }, - { szOID_RSA_RC4, NULL, CALG_RC4 }, - { szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES }, - { szOID_ANSI_X942_DH, NULL, CALG_DH_SF }, - { szOID_X957_DSA, szOID_OIWSEC_dsa /* some Win98 */, CALG_DSS_SIGN }, - { szOID_OIWSEC_desCBC, NULL, CALG_DES }, - { szOID_OIWSEC_sha1, NULL, CALG_SHA }, + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_sha1, CALG_SHA }, }; -static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 }; -static const WCHAR bogus2Dll[] = { 'b','o','g','u','s','2','.','d','l','l',0 }; - -static void testOIDToAlgID(void) +static void test_OIDToAlgID(void) { int i; DWORD alg; /* Test with a bogus one */ alg = CertOIDToAlgId("1.2.3"); - ok(!alg, "Expected failure, got %d\n", alg); + ok(!alg, "Expected failure, got %ld\n", alg); for (i = 0; i < ARRAY_SIZE(oidToAlgID); i++) { alg = CertOIDToAlgId(oidToAlgID[i].oid); ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID), - "Expected %d, got %d\n", oidToAlgID[i].algID, alg); + "Expected %ld, got %ld\n", oidToAlgID[i].algID, alg); } } -static void testAlgIDToOID(void) +static void test_AlgIDToOID(void) { int i; LPCSTR oid; @@ -124,32 +117,14 @@ static void testAlgIDToOID(void) SetLastError(0xdeadbeef); oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80); ok(!oid && GetLastError() == 0xdeadbeef, - "Didn't expect last error (%08x) to be set\n", GetLastError()); + "Didn't expect last error (%08lx) to be set\n", GetLastError()); for (i = 0; i < ARRAY_SIZE(algIDToOID); i++) { oid = CertAlgIdToOID(algIDToOID[i].algID); /* Allow failure, not every version of Windows supports every algo */ - ok(oid != NULL || broken(!oid), "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid); + ok(oid != NULL, "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid); if (oid) - { - if (strcmp(oid, algIDToOID[i].oid)) - { - if (algIDToOID[i].altOid) - ok(!strcmp(oid, algIDToOID[i].altOid), - "Expected %s or %s, got %s\n", algIDToOID[i].oid, - algIDToOID[i].altOid, oid); - else - { - /* No need to rerun the test, we already know it failed. */ - ok(0, "Expected %s, got %s\n", algIDToOID[i].oid, oid); - } - } - else - { - /* No need to rerun the test, we already know it succeeded. */ - ok(1, "Expected %s, got %s\n", algIDToOID[i].oid, oid); - } - } + ok(!strcmp(oid, algIDToOID[i].oid), "Expected %s, got %s\n", algIDToOID[i].oid, oid); } } @@ -166,7 +141,7 @@ static void test_oidFunctionSet(void) /* The name doesn't mean much */ set1 = CryptInitOIDFunctionSet("funky", 0); - ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError()); + ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError()); if (set1) { /* These crash @@ -175,26 +150,26 @@ static void test_oidFunctionSet(void) */ size = 0; ret = CryptGetDefaultOIDDllList(set1, 0, NULL, &size); - ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n", GetLastError()); + ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n", GetLastError()); if (ret) { - buf = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); + buf = malloc(size * sizeof(WCHAR)); if (buf) { ret = CryptGetDefaultOIDDllList(set1, 0, buf, &size); - ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n", + ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n", GetLastError()); ok(!*buf, "Expected empty DLL list\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } } } /* MSDN says flags must be 0, but it's not checked */ set1 = CryptInitOIDFunctionSet("", 1); - ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError()); + ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError()); set2 = CryptInitOIDFunctionSet("", 0); - ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError()); + ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError()); /* There isn't a free function, so there must be only one set per name to * limit leaks. (I guess the sets are freed when crypt32 is unloaded.) */ @@ -208,7 +183,7 @@ static void test_oidFunctionSet(void) /* There's no installed function for a built-in encoding. */ set1 = CryptInitOIDFunctionSet("CryptDllEncodeObject", 0); - ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError()); + ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError()); if (set1) { void *funcAddr; @@ -216,9 +191,8 @@ static void test_oidFunctionSet(void) ret = CryptGetOIDFunctionAddress(set1, X509_ASN_ENCODING, X509_CERT, 0, &funcAddr, &hFuncAddr); - ok((!ret && GetLastError() == ERROR_FILE_NOT_FOUND) || - broken(ret) /* some Win98 */, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); } } @@ -243,21 +217,21 @@ static void test_installOIDFunctionAddress(void) SetLastError(0xdeadbeef); ret = CryptInstallOIDFunctionAddress(NULL, 0, "CryptDllEncodeObject", 0, NULL, 0); - ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n", + ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n", GetLastError()); /* The function name doesn't much matter */ SetLastError(0xdeadbeef); ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 0, NULL, 0); - ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n", + ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n", GetLastError()); SetLastError(0xdeadbeef); entry.pszOID = X509_CERT; ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 1, &entry, 0); - ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n", + ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n", GetLastError()); set = CryptInitOIDFunctionSet("OhSoFunky", 0); - ok(set != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError()); + ok(set != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError()); if (set) { funcY funcAddr = NULL; @@ -269,17 +243,15 @@ static void test_installOIDFunctionAddress(void) */ ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0, (void **)&funcAddr, &hFuncAddr); - ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND || - GetLastError() == E_INVALIDARG /* some Win98 */), - "Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %d\n", - GetLastError()); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0, (void **)&funcAddr, &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); ret = CryptGetOIDFunctionAddress(set, 0, X509_CERT, 0, (void **)&funcAddr, &hFuncAddr); - ok(ret, "CryptGetOIDFunctionAddress failed: %d\n", GetLastError()); + ok(ret, "CryptGetOIDFunctionAddress failed: %ld\n", GetLastError()); if (funcAddr) { int y = funcAddr(0xabadc0da); @@ -298,55 +270,55 @@ static void test_registerOIDFunction(void) * omitted. This may be a side effect of the registry code, I don't know. * I don't check it because I doubt anyone would depend on it. ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, NULL, - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); */ /* On windows XP, GetLastError is incorrectly being set with an HRESULT, * E_INVALIDARG */ - ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll, + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, L"bogus.dll", NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG: %d\n", GetLastError()); + "Expected E_INVALIDARG: %ld\n", GetLastError()); /* This has no effect, but "succeeds" on XP */ ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", "1.2.3.4.5.6.7.8.9.10", NULL, NULL); - ok(ret, "Expected pseudo-success, got %d\n", GetLastError()); + ok(ret, "Expected pseudo-success, got %ld\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) { skip("Need admin rights\n"); return; } - ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); - ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); - ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError()); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus", "1.2.3.4.5.6.7.8.9.10"); - ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); /* Unwanted Cryptography\OID\EncodingType 1\bogus\ will still be there */ ok(!RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography\\OID\\EncodingType 1\\bogus"), "Could not delete bogus key\n"); /* Shouldn't have effect but registry keys are created */ ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); - ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError()); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); - ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); /* Check with bogus encoding type. Registry keys are still created */ ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); - ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError()); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(0, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); - ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); /* Unwanted Cryptography\OID\EncodingType 0\CryptDllEncodeObject\ * will still be there */ @@ -357,11 +329,11 @@ static void test_registerOIDFunction(void) * (for now) treated as a mask. Registry keys are created. */ ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject", - "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); - ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError()); + "1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject", "1.2.3.4.5.6.7.8.9.10"); - ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError()); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); /* Unwanted Cryptography\OID\EncodingType 3\CryptDllEncodeObject * will still be there. */ @@ -385,84 +357,81 @@ static void test_registerDefaultOIDFunction(void) ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This succeeds on WinXP, although the bogus entry is unusable. - ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, bogusDll); + ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, L"bogus.dll"); */ /* Register one at index 0 */ SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) { skip("Need admin rights\n"); return; } - ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError()); + ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError()); /* Reregistering should fail */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_EXISTS, - "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError()); + "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Registering the same one at index 1 should also fail */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1, - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_EXISTS, - "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError()); + "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Registering a different one at index 1 succeeds */ ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1, - bogus2Dll); - ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError()); + L"bogus2.dll"); + ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError()); sprintf(buf, fmt, 0, func); rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, buf, &key); - ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %d\n", rc); + ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %ld\n", rc); if (rc == 0) { - static const CHAR dllA[] = "Dll"; - static const CHAR bogusDll_A[] = "bogus.dll"; - static const CHAR bogus2Dll_A[] = "bogus2.dll"; CHAR dllBuf[MAX_PATH]; DWORD type, size; LPSTR ptr; size = ARRAY_SIZE(dllBuf); - rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size); + rc = RegQueryValueExA(key, "Dll", NULL, &type, (LPBYTE)dllBuf, &size); ok(rc == 0, - "Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc); - ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %d\n", type); - /* bogusDll was registered first, so that should be first */ + "Expected Dll value to exist, RegQueryValueExA failed: %ld\n", rc); + ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %ld\n", type); + /* bogus.dll was registered first, so that should be first */ ptr = dllBuf; - ok(!lstrcmpiA(ptr, bogusDll_A), "Unexpected dll\n"); + ok(!lstrcmpiA(ptr, "bogus.dll"), "Unexpected dll\n"); ptr += lstrlenA(ptr) + 1; - ok(!lstrcmpiA(ptr, bogus2Dll_A), "Unexpected dll\n"); + ok(!lstrcmpiA(ptr, "bogus2.dll"), "Unexpected dll\n"); RegCloseKey(key); } /* Unregister both of them */ ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogusDll); - ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n", + L"bogus.dll"); + ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n", GetLastError()); ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogus2Dll); - ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n", + L"bogus2.dll"); + ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n", GetLastError()); /* Now that they're both unregistered, unregistering should fail */ ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", - bogusDll); + L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* Repeat a few tests on the normal encoding type */ ret = CryptRegisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", 0, bogusDll); + "CertDllOpenStoreProv", 0, L"bogus.dll"); ok(ret, "CryptRegisterDefaultOIDFunction failed\n"); ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", bogusDll); + "CertDllOpenStoreProv", L"bogus.dll"); ok(ret, "CryptUnregisterDefaultOIDFunction failed\n"); ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING, - "CertDllOpenStoreProv", bogusDll); + "CertDllOpenStoreProv", L"bogus.dll"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); } static void test_getDefaultOIDFunctionAddress(void) @@ -480,34 +449,34 @@ static void test_getDefaultOIDFunctionAddress(void) &hFuncAddr); */ set = CryptInitOIDFunctionSet("CertDllOpenStoreProv", 0); - ok(set != 0, "CryptInitOIDFunctionSet failed: %d\n", GetLastError()); + ok(set != 0, "CryptInitOIDFunctionSet failed: %ld\n", GetLastError()); /* This crashes if hFuncAddr is not 0 to begin with */ hFuncAddr = 0; ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr, &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* This fails with the normal encoding too, so built-in functions aren't * returned. */ ret = CryptGetDefaultOIDFunctionAddress(set, X509_ASN_ENCODING, NULL, 0, &funcAddr, &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* Even with a registered dll, this fails (since the dll doesn't exist) */ SetLastError(0xdeadbeef); ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0, - bogusDll); + L"bogus.dll"); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) skip("Need admin rights\n"); else - ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError()); + ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError()); ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr, &hFuncAddr); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", bogusDll); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); + CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", L"bogus.dll"); } static BOOL WINAPI countOidInfo(PCCRYPT_OID_INFO pInfo, void *pvArg) @@ -526,29 +495,22 @@ static void test_enumOIDInfo(void) BOOL ret; DWORD count = 0; - if (!pCryptEnumOIDInfo) - { - win_skip("CryptEnumOIDInfo() is not available\n"); - return; - } - /* This crashes - ret = pCryptEnumOIDInfo(7, 0, NULL, NULL); + ret = CryptEnumOIDInfo(7, 0, NULL, NULL); */ /* Silly tests, check that more than one thing is enumerated */ - ret = pCryptEnumOIDInfo(0, 0, &count, countOidInfo); + ret = CryptEnumOIDInfo(0, 0, &count, countOidInfo); ok(ret && count > 0, "Expected more than item enumerated\n"); - ret = pCryptEnumOIDInfo(0, 0, NULL, noOidInfo); + ret = CryptEnumOIDInfo(0, 0, NULL, noOidInfo); ok(!ret, "Expected FALSE\n"); } static void test_findOIDInfo(void) { - static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; - static WCHAR sha1[] = { 's','h','a','1',0 }; static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256; + static CHAR oid_ecc_public_key[] = szOID_ECC_PUBLIC_KEY; ALG_ID alg = CALG_SHA1; ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN }; const struct oid_info @@ -561,7 +523,7 @@ static void test_findOIDInfo(void) } oid_test_info [] = { { CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, szOID_RSA_MD5, CALG_MD5 }, - { CRYPT_OID_INFO_NAME_KEY, sha1, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_NAME_KEY, (void *)L"sha1", szOID_OIWSEC_sha1, CALG_SHA1 }, { CRYPT_OID_INFO_ALGID_KEY, &alg, szOID_OIWSEC_sha1, CALG_SHA1 }, { CRYPT_OID_INFO_SIGN_KEY, algs, szOID_RSA_MD5RSA, CALG_MD5 }, { CRYPT_OID_INFO_OID_KEY, oid_sha256, szOID_NIST_sha256, CALG_SHA_256, -1 }, @@ -581,8 +543,8 @@ static void test_findOIDInfo(void) if (info) { ok(!strcmp(info->pszOID, test->oid), "Unexpected OID %s, expected %s\n", info->pszOID, test->oid); - ok(U(*info).Algid == test->algid || broken(U(*info).Algid == test->broken_algid), - "Unexpected Algid %d, expected %d\n", U(*info).Algid, test->algid); + ok(info->Algid == test->algid || broken(info->Algid == test->broken_algid), + "Unexpected Algid %d, expected %d\n", info->Algid, test->algid); } } @@ -591,20 +553,20 @@ static void test_findOIDInfo(void) { DWORD *data; - ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\n", info->cbSize); + ok(info->cbSize == sizeof(*info), "Unexpected structure size %ld.\n", info->cbSize); ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID); - ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n", - wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); + ok(!lstrcmpW(info->pwszName, L"sha256ECDSA"), "Expected %s, got %s\n", + wine_dbgstr_w(L"sha256ECDSA"), wine_dbgstr_w(info->pwszName)); ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID, - "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId); - ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY, - "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid); + "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %lu\n", info->dwGroupId); + ok(info->Algid == CALG_OID_INFO_CNG_ONLY, + "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", info->Algid); data = (DWORD *)info->ExtraInfo.pbData; - ok(info->ExtraInfo.cbData == 8, "Expected 8, got %d\n", info->ExtraInfo.cbData); - ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]); + ok(info->ExtraInfo.cbData == 8, "Expected 8, got %ld\n", info->ExtraInfo.cbData); + ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %lx\n", data[0]); ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, - "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]); + "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %lx\n", data[1]); ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n", wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid)); @@ -613,11 +575,21 @@ static void test_findOIDInfo(void) } else win_skip("Host does not support ECDSA_SHA256, skipping test\n"); + + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecc_public_key, 0); + ok(!!info, "got error %#lx.\n", GetLastError()); + ok(!strcmp(info->pszOID, oid_ecc_public_key), "got %s.\n", info->pszOID); + ok(!wcscmp(info->pwszName, L"ECC"), "got %s.\n", wine_dbgstr_w(info->pwszName)); + ok(info->dwGroupId == CRYPT_PUBKEY_ALG_OID_GROUP_ID, "got %lu.\n", info->dwGroupId); + ok(info->Algid == CALG_OID_INFO_PARAMETERS, "got %d.\n", info->Algid); + ok(!info->ExtraInfo.cbData, "got %ld.\n", info->ExtraInfo.cbData); + ok(!wcscmp(info->pwszCNGAlgid, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), "got %s.\n", wine_dbgstr_w(info->pwszCNGAlgid)); + ok(info->pwszCNGExtraAlgid && !wcscmp(info->pwszCNGExtraAlgid, L""), "got %s.\n", + wine_dbgstr_w(info->pwszCNGExtraAlgid)); } static void test_registerOIDInfo(void) { - static const WCHAR winetestW[] = { 'w','i','n','e','t','e','s','t',0 }; static char test_oid[] = "1.2.3.4.5.6.7.8.9.10"; CRYPT_OID_INFO info1; const CRYPT_OID_INFO *info2; @@ -628,25 +600,26 @@ static void test_registerOIDInfo(void) SetLastError(0xdeadbeef); ret = CryptUnregisterOIDInfo(NULL); ok(!ret, "should fail\n"); - ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError()); + ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError()); memset(&info1, 0, sizeof(info1)); SetLastError(0xdeadbeef); ret = CryptUnregisterOIDInfo(&info1); ok(!ret, "should fail\n"); - ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError()); + ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError()); info1.cbSize = sizeof(info1); SetLastError(0xdeadbeef); ret = CryptUnregisterOIDInfo(&info1); ok(!ret, "should fail\n"); - ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError()); + ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError()); info1.pszOID = test_oid; SetLastError(0xdeadbeef); ret = CryptUnregisterOIDInfo(&info1); ok(!ret, "should fail\n"); - ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got %u\n", GetLastError()); + ok(GetLastError() == ERROR_FILE_NOT_FOUND || + GetLastError() == ERROR_ACCESS_DENIED, "got %lu\n", GetLastError()); info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0); ok(!info2, "should fail\n"); @@ -656,15 +629,15 @@ static void test_registerOIDInfo(void) * registry on Windows because dwGroupId == 0. */ ret = CryptRegisterOIDInfo(&info1, 0); - ok(ret, "got %u\n", GetLastError()); + ok(ret, "got %lu\n", GetLastError()); ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key); - ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret); + ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret); info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0); ok(!info2, "should fail\n"); - info1.pwszName = winetestW; + info1.pwszName = L"winetest"; info1.dwGroupId = CRYPT_HASH_ALG_OID_GROUP_ID; SetLastError(0xdeadbeef); ret = CryptRegisterOIDInfo(&info1, CRYPT_INSTALL_OID_INFO_BEFORE_FLAG); @@ -673,7 +646,7 @@ static void test_registerOIDInfo(void) skip("Need admin rights\n"); return; } - ok(ret, "got %u\n", GetLastError()); + ok(ret, "got %lu\n", GetLastError()); /* It looks like crypt32 reads the OID info from registry only on load, * and CryptFindOIDInfo will find the registered OID on next run @@ -682,38 +655,38 @@ static void test_registerOIDInfo(void) ok(!info2, "should fail\n"); ret = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key); - ok(!ret, "got %u\n", ret); + ok(!ret, "got %lu\n", ret); memset(buf, 0, sizeof(buf)); size = sizeof(buf); ret = RegQueryValueExA(key, "Name", NULL, &type, (BYTE *)buf, &size); - ok(!ret, "got %u\n", ret); - ok(type == REG_SZ, "got %u\n", type); + ok(!ret, "got %lu\n", ret); + ok(type == REG_SZ, "got %lu\n", type); ok(!strcmp(buf, "winetest"), "got %s\n", buf); value = 0xdeadbeef; size = sizeof(value); ret = RegQueryValueExA(key, "Flags", NULL, &type, (BYTE *)&value, &size); - ok(!ret, "got %u\n", ret); - ok(type == REG_DWORD, "got %u\n", type); - ok(value == 1, "got %u\n", value); + ok(!ret, "got %lu\n", ret); + ok(type == REG_DWORD, "got %lu\n", type); + ok(value == 1, "got %lu\n", value); RegCloseKey(key); CryptUnregisterOIDInfo(&info1); ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key); - ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret); + ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret); } START_TEST(oid) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptEnumOIDInfo = (void*)GetProcAddress(hCrypt32, "CryptEnumOIDInfo"); - - testOIDToAlgID(); - testAlgIDToOID(); + test_OIDToAlgID(); + test_AlgIDToOID(); test_enumOIDInfo(); +#ifdef __REACTOS__ + if ((GetVersion() & 0xFF) > 5) // test_findOIDInfo() crashes on Server 2003 +#endif test_findOIDInfo(); test_registerOIDInfo(); test_oidFunctionSet(); diff --git a/modules/rostests/winetests/crypt32/protectdata.c b/modules/rostests/winetests/crypt32/protectdata.c index 70a8ba86b05..362f1faddb4 100644 --- a/modules/rostests/winetests/crypt32/protectdata.c +++ b/modules/rostests/winetests/crypt32/protectdata.c @@ -27,13 +27,9 @@ #include "wine/test.h" -static BOOL (WINAPI *pCryptProtectData)(DATA_BLOB*,LPCWSTR,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); -static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); - static char secret[] = "I am a super secret string that no one can see!"; static char secret2[] = "I am a super secret string indescribable string"; static char key[] = "Wibble wibble wibble"; -static const WCHAR desc[] = {'U','l','t','r','a',' ','s','e','c','r','e','t',' ','t','e','s','t',' ','m','e','s','s','a','g','e',0}; static BOOL protected = FALSE; /* if true, the unprotect tests can run */ static DATA_BLOB cipher; static DATA_BLOB cipher_entropy; @@ -52,32 +48,28 @@ static void test_cryptprotectdata(void) entropy.cbData=strlen(key)+1; SetLastError(0xDEADBEEF); - protected = pCryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher); + protected = CryptProtectData(NULL, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); ok(!protected, "Encrypting without plain data source.\n"); r = GetLastError(); - ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); + ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL); + protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, NULL); ok(!protected, "Encrypting without cipher destination.\n"); r = GetLastError(); - ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); + ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); cipher.pbData=NULL; cipher.cbData=0; /* without entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher); - ok(protected || - broken(!protected), /* Win9x/NT4 */ - "Encrypting without entropy.\n"); + protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher); + ok(protected, "Encrypting without entropy.\n"); if (protected) { r = GetLastError(); - ok(r == ERROR_SUCCESS || - r == ERROR_IO_PENDING, /* win2k */ - "Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %d\n",r); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n",r); } cipher_entropy.pbData=NULL; @@ -85,10 +77,8 @@ static void test_cryptprotectdata(void) /* with entropy */ SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy); - ok(protected || - broken(!protected), /* Win9x/NT4 */ - "Encrypting with entropy.\n"); + protected = CryptProtectData(&plain, L"Ultra secret test message", &entropy, NULL, NULL, 0, &cipher_entropy); + ok(protected, "Encrypting with entropy.\n"); cipher_no_desc.pbData=NULL; cipher_no_desc.cbData=0; @@ -97,13 +87,8 @@ static void test_cryptprotectdata(void) plain.pbData=(void*)secret2; plain.cbData=strlen(secret2)+1; SetLastError(0xDEADBEEF); - protected = pCryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); - if (!protected) - { - /* fails in win2k */ - ok(GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - } + protected = CryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); + ok(protected, "Encrypting with entropy.\n"); } static void test_cryptunprotectdata(void) @@ -117,36 +102,29 @@ static void test_cryptunprotectdata(void) entropy.pbData=(void*)key; entropy.cbData=strlen(key)+1; - /* fails in win2k */ - if (!protected) - { - skip("CryptProtectData failed to run\n"); - return; - } - plain.pbData=NULL; plain.cbData=0; SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); + okay = CryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); ok(!okay,"Decrypting without destination\n"); r = GetLastError(); - ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); + ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without source\n"); r = GetLastError(); - ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); + ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r); plain.pbData=NULL; plain.cbData=0; SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without needed entropy\n"); r = GetLastError(); - ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n", r); + ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n", r); plain.pbData=NULL; plain.cbData=0; @@ -154,14 +132,14 @@ static void test_cryptunprotectdata(void) /* without entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); ok(okay,"Decrypting without entropy\n"); ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n"); ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n"); ok(data_desc!=NULL,"Description not allocated\n"); - ok(!lstrcmpW(data_desc,desc),"Description does not match\n"); + ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n"); LocalFree(plain.pbData); LocalFree(data_desc); @@ -172,21 +150,21 @@ static void test_cryptunprotectdata(void) /* with wrong entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); ok(!okay,"Decrypting with wrong entropy\n"); r = GetLastError(); - ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n",r); + ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n",r); /* with entropy */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy\n"); ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n"); ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n"); ok(data_desc!=NULL,"Description not allocated\n"); - ok(!lstrcmpW(data_desc,desc),"Description does not match\n"); + ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n"); LocalFree(plain.pbData); LocalFree(data_desc); @@ -197,7 +175,7 @@ static void test_cryptunprotectdata(void) /* with entropy but no description */ SetLastError(0xDEADBEEF); - okay = pCryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = CryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy and no description\n"); ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n"); @@ -224,18 +202,12 @@ static void test_simpleroundtrip(const char *plaintext) emptyW[0] = 0; input.pbData = (unsigned char *)plaintext; input.cbData = strlen(plaintext); - res = pCryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted); - ok(res != 0 || broken(!res), "can't protect\n"); - if (!res) - { - /* Fails on Win9x, NT4 */ - win_skip("CryptProtectData failed\n"); - return; - } + res = CryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted); + ok(res != 0, "can't protect\n"); - res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output); - ok(res != 0, "can't unprotect; last error %u\n", GetLastError()); - ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext)); + res = CryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output); + ok(res != 0, "can't unprotect; last error %lu\n", GetLastError()); + ok(output.cbData == strlen(plaintext), "output wrong length %ld for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext)); ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext); LocalFree(output.pbData); LocalFree(encrypted.pbData); @@ -243,16 +215,7 @@ static void test_simpleroundtrip(const char *plaintext) START_TEST(protectdata) { - HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); - pCryptProtectData = (void*)GetProcAddress(hCrypt32, "CryptProtectData"); - pCryptUnprotectData = (void*)GetProcAddress(hCrypt32, "CryptUnprotectData"); - if (!pCryptProtectData || !pCryptUnprotectData) - { - win_skip("Crypt(Un)ProtectData() is not available\n"); - return; - } - - protected=FALSE; + protected = FALSE; test_cryptprotectdata(); test_cryptunprotectdata(); test_simpleroundtrip(""); diff --git a/modules/rostests/winetests/crypt32/sip.c b/modules/rostests/winetests/crypt32/sip.c index d8d6a874450..1a61c558dd0 100644 --- a/modules/rostests/winetests/crypt32/sip.c +++ b/modules/rostests/winetests/crypt32/sip.c @@ -41,15 +41,13 @@ static void test_AddRemoveProvider(void) BOOL ret; SIP_ADD_NEWPROVIDER newprov; GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }}; - static WCHAR dummydll[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 }; - static WCHAR dummyfunction[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 }; /* NULL check */ SetLastError(0xdeadbeef); ret = CryptSIPRemoveProvider(NULL); ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n"); ok (GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError()); /* nonexistent provider should result in a registry error */ SetLastError(0xdeadbeef); @@ -59,17 +57,6 @@ static void test_AddRemoveProvider(void) /* Apparently the needed rights are checked before the existence of the provider */ skip("Need admin rights\n"); } - else - { - /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if - * the arguments are correct, whether or not the registry key is - * present, so don't test ret, just check the last error if it does - * return FALSE. - */ - if (!ret) - ok (GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError()); - } /* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL * as allowed */ @@ -77,12 +64,12 @@ static void test_AddRemoveProvider(void) memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER)); newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER); newprov.pgSubject = &actionid; - newprov.pwszDLLFileName = dummydll; - newprov.pwszGetFuncName = dummyfunction; - newprov.pwszPutFuncName = dummyfunction; - newprov.pwszCreateFuncName = dummyfunction; - newprov.pwszVerifyFuncName = dummyfunction; - newprov.pwszRemoveFuncName = dummyfunction; + newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll"; + newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction"; SetLastError(0xdeadbeef); ret = CryptSIPAddProvider(&newprov); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) @@ -90,7 +77,7 @@ static void test_AddRemoveProvider(void) skip("Need admin rights\n"); return; } - ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError()); + ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError()); /* Dummy provider will be deleted, but the function still fails because * pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the @@ -98,38 +85,32 @@ static void test_AddRemoveProvider(void) */ SetLastError(0xdeadbeef); ret = CryptSIPRemoveProvider(&actionid); - /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if - * the arguments are correct, whether or not the registry key is - * present, so don't test ret, just check the last error if it does - * return FALSE. - */ - if (!ret) - ok (GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError()); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError()); /* Everything OK */ memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER)); newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER); newprov.pgSubject = &actionid; - newprov.pwszDLLFileName = dummydll; - newprov.pwszGetFuncName = dummyfunction; - newprov.pwszPutFuncName = dummyfunction; - newprov.pwszCreateFuncName = dummyfunction; - newprov.pwszVerifyFuncName = dummyfunction; - newprov.pwszRemoveFuncName = dummyfunction; - newprov.pwszIsFunctionNameFmt2 = dummyfunction; - newprov.pwszIsFunctionName = dummyfunction; + newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll"; + newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction"; + newprov.pwszIsFunctionNameFmt2 = (WCHAR *)L"dummyfunction"; + newprov.pwszIsFunctionName = (WCHAR *)L"dummyfunction"; /* If GetCapFuncName set to NULL, then CryptSIPRemoveProvider fails on win 8 */ - newprov.pwszGetCapFuncName = dummyfunction; + newprov.pwszGetCapFuncName = (WCHAR *)L"dummyfunction"; SetLastError(0xdeadbeef); ret = CryptSIPAddProvider(&newprov); - ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError()); + ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError()); /* Dummy provider should be deleted */ SetLastError(0xdeadbeef); ret = CryptSIPRemoveProvider(&actionid); - ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %d\n", GetLastError()); + ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %ld\n", GetLastError()); } static const BYTE cabFileData[] = { @@ -148,7 +129,6 @@ static void test_SIPRetrieveSubjectGUID(void) static const CHAR windir[] = "windir"; static const CHAR regeditExe[] = "regedit.exe"; static const GUID nullSubject = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }}; - static const WCHAR deadbeef[] = { 'c',':','\\','d','e','a','d','b','e','e','f','.','d','b','f',0 }; /* Couldn't find a name for this GUID, it's the one used for 95% of the files */ static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }}; @@ -164,17 +144,17 @@ static void test_SIPRetrieveSubjectGUID(void) ret = CryptSIPRetrieveSubjectGuid(NULL, NULL, NULL); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); ok (GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError()); /* Test with a nonexistent file (hopefully) */ SetLastError(0xdeadbeef); /* Set subject to something other than zeros */ memset(&subject, 1, sizeof(GUID)); - ret = CryptSIPRetrieveSubjectGuid(deadbeef, NULL, &subject); + ret = CryptSIPRetrieveSubjectGuid(L"c:\\deadbeef.dbf", NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); ok (GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %d.\n", + "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %ld.\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", wine_dbgstr_guid(&subject)); @@ -184,7 +164,7 @@ static void test_SIPRetrieveSubjectGUID(void) * Use A-functions where possible as that should be available on all platforms */ ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH); - ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError()); + ok (ret > 0, "expected GEVA(windir) to succeed, last error %ld\n", GetLastError()); strcat(regeditPath, "\\"); strcat(regeditPath, regeditExe); MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW, @@ -226,11 +206,8 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == ERROR_FILE_INVALID || - GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ || - GetLastError() == ERROR_SUCCESS /* most Win98 */ || - GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */, - "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError()); + ok ( GetLastError() == ERROR_FILE_INVALID || GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject)); @@ -243,10 +220,8 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == ERROR_INVALID_PARAMETER || - GetLastError() == ERROR_SUCCESS /* most Win98 */ || - GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */, - "Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError()); + ok ( GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject)); @@ -259,9 +234,8 @@ static void test_SIPRetrieveSubjectGUID(void) memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n"); - ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN || - GetLastError() == ERROR_SUCCESS /* Win98 */, - "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08x\n", GetLastError()); + ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN, + "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08lx\n", GetLastError()); ok(IsEqualGUID(&subject, &nullSubject), "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject)); @@ -271,14 +245,14 @@ static void test_SIPRetrieveSubjectGUID(void) /* Create a file with just the .cab header 'MSCF' */ SetLastError(0xdeadbeef); file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL); - ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError()); + ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError()); WriteFile(file, cabFileData, 4, &written, NULL); CloseHandle(file); SetLastError(0xdeadbeef); memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); - ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n", + ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n", GetLastError(), GetLastError() ); ok(IsEqualGUID(&subject, &cabGUID), "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject)); @@ -289,14 +263,14 @@ static void test_SIPRetrieveSubjectGUID(void) /* Create a .cab file */ SetLastError(0xdeadbeef); file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL); - ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError()); + ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError()); WriteFile(file, cabFileData, sizeof(cabFileData), &written, NULL); CloseHandle(file); SetLastError(0xdeadbeef); memset(&subject, 1, sizeof(GUID)); ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject); - ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n", + ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n", GetLastError(), GetLastError() ); ok(IsEqualGUID(&subject, &cabGUID), "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject)); @@ -322,14 +296,14 @@ static void test_SIPLoad(void) ret = CryptSIPLoad(NULL, 0, NULL); ok ( !ret, "Expected CryptSIPLoad to fail\n"); ok ( GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); /* Only pSipDispatch NULL */ SetLastError(0xdeadbeef); ret = CryptSIPLoad(&subject, 0, NULL); ok ( !ret, "Expected CryptSIPLoad to fail\n"); ok ( GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); /* No NULLs, but nonexistent pgSubject */ SetLastError(0xdeadbeef); @@ -339,7 +313,7 @@ static void test_SIPLoad(void) ret = CryptSIPLoad(&dummySubject, 0, &sdi); ok ( !ret, "Expected CryptSIPLoad to fail\n"); ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN, - "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError()); + "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError()); ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n"); hCrypt = GetModuleHandleA("crypt32.dll"); @@ -430,7 +404,7 @@ static void test_SIPLoad(void) ret = CryptSIPLoad(&unknown, 1, &sdi); ok ( !ret, "Expected CryptSIPLoad to fail\n"); ok ( GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError()); ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n"); } diff --git a/modules/rostests/winetests/crypt32/store.c b/modules/rostests/winetests/crypt32/store.c index d862902c88d..7e66e6523d0 100644 --- a/modules/rostests/winetests/crypt32/store.c +++ b/modules/rostests/winetests/crypt32/store.c @@ -136,66 +136,64 @@ static void testMemStore(void) /* NULL provider */ store1 = CertOpenStore(0, 0, 0, 0, NULL); ok(!store1 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); /* weird flags */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_DELETE_FLAG, NULL); ok(!store1 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "Expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError()); + "Expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError()); /* normal */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store1 != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError()); /* open existing doesn't */ store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG, NULL); - ok(store2 != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ok(store1 != store2, "Expected different stores\n"); /* add a bogus (empty) cert */ context = NULL; ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, emptyCert, sizeof(emptyCert), CERT_STORE_ADD_ALWAYS, &context); - /* Windows returns CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, but accept + /* Windows returns CRYPT_E_ASN1_EOD, but accept * CRYPT_E_ASN1_CORRUPT as well (because matching errors is tough in this * case) */ GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == CRYPT_E_ASN1_CORRUPT || - GLE == OSS_DATA_ERROR), - "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", + ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GLE); /* add a "signed" cert--the signature isn't a real signature, so this adds * without any check of the signature's validity */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, signedBigCert, sizeof(signedBigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a valid cert context\n"); if (context) { ok(context->cbCertEncoded == sizeof(signedBigCert), - "Wrong cert size %d\n", context->cbCertEncoded); + "Wrong cert size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, signedBigCert, sizeof(signedBigCert)), "Unexpected encoded cert in context\n"); /* remove it, the rest of the tests will work on an unsigned cert */ ret = CertDeleteCertificateFromStore(context); - ok(ret, "CertDeleteCertificateFromStore failed: %08x\n", + ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n", GetLastError()); } /* try adding a "signed" CRL as a cert */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context); GLE = GetLastError(); - ok(!ret && (GLE == CRYPT_E_ASN1_BADTAG || GLE == CRYPT_E_ASN1_CORRUPT || - GLE == OSS_DATA_ERROR), - "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n", + ok(!ret && (GLE == CRYPT_E_ASN1_BADTAG || GLE == CRYPT_E_ASN1_CORRUPT), + "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT, got %08lx\n", GLE); /* add a cert to store1 */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a valid cert context\n"); if (context) { @@ -203,7 +201,7 @@ static void testMemStore(void) BYTE *buf; ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong cert size %d\n", context->cbCertEncoded); + "Wrong cert size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)), "Unexpected encoded cert in context\n"); ok(context->hCertStore == store1, "Unexpected store\n"); @@ -216,28 +214,28 @@ static void testMemStore(void) */ /* apparently flags are ignored */ ret = CertSerializeCertificateStoreElement(context, 1, NULL, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertSerializeCertificateStoreElement(context, 0, buf, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", GetLastError()); - ok(size == sizeof(serializedCert), "Wrong size %d\n", size); + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); + ok(size == sizeof(serializedCert), "Wrong size %ld\n", size); ok(!memcmp(serializedCert, buf, size), "Unexpected serialized cert\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } ret = CertFreeCertificateContext(context); - ok(ret, "CertFreeCertificateContext failed: %08x\n", GetLastError()); + ok(ret, "CertFreeCertificateContext failed: %08lx\n", GetLastError()); } /* verify the cert's in store1 */ context = CertEnumCertificatesInStore(store1, NULL); ok(context != NULL, "Expected a valid context\n"); context = CertEnumCertificatesInStore(store1, context); ok(!context && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* verify store2 (the "open existing" mem store) is still empty */ context = CertEnumCertificatesInStore(store2, NULL); ok(!context, "Expected an empty store\n"); @@ -254,14 +252,14 @@ static void testMemStore(void) */ PCCERT_CONTEXT copy = CertDuplicateCertificateContext(context); - ok(copy != NULL, "CertDuplicateCertificateContext failed: %08x\n", + ok(copy != NULL, "CertDuplicateCertificateContext failed: %08lx\n", GetLastError()); ret = CertDeleteCertificateFromStore(context); - ok(ret, "CertDeleteCertificateFromStore failed: %08x\n", + ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n", GetLastError()); /* try deleting a copy */ ret = CertDeleteCertificateFromStore(copy); - ok(ret, "CertDeleteCertificateFromStore failed: %08x\n", + ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n", GetLastError()); /* check that the store is empty */ context = CertEnumCertificatesInStore(store1, NULL); @@ -270,32 +268,32 @@ static void testMemStore(void) /* close an empty store */ ret = CertCloseStore(NULL, 0); - ok(ret, "CertCloseStore failed: %d\n", GetLastError()); + ok(ret, "CertCloseStore failed: %ld\n", GetLastError()); ret = CertCloseStore(store1, 0); - ok(ret, "CertCloseStore failed: %d\n", GetLastError()); + ok(ret, "CertCloseStore failed: %ld\n", GetLastError()); ret = CertCloseStore(store2, 0); - ok(ret, "CertCloseStore failed: %d\n", GetLastError()); + ok(ret, "CertCloseStore failed: %ld\n", GetLastError()); /* This seems nonsensical, but you can open a read-only mem store, only * it isn't read-only */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_READONLY_FLAG, NULL); - ok(store1 != NULL, "CertOpenStore failed: %d\n", GetLastError()); + ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError()); /* yep, this succeeds */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ok(context != NULL, "Expected a valid cert context\n"); if (context) { ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong cert size %d\n", context->cbCertEncoded); + "Wrong cert size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)), "Unexpected encoded cert in context\n"); ok(context->hCertStore == store1, "Unexpected store\n"); ret = CertDeleteCertificateFromStore(context); - ok(ret, "CertDeleteCertificateFromStore failed: %08x\n", + ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n", GetLastError()); } CertCloseStore(store1, 0); @@ -309,19 +307,19 @@ static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb, ret = CertSaveStore(store, X509_ASN_ENCODING, CERT_STORE_SAVE_AS_STORE, CERT_STORE_SAVE_TO_MEMORY, &blob, 0); - ok(ret, "CertSaveStore failed: %08x\n", GetLastError()); + ok(ret, "CertSaveStore failed: %08lx\n", GetLastError()); todo_wine_if (todo) - ok(blob.cbData == cb, "%s: expected size %d, got %d\n", name, cb, + ok(blob.cbData == cb, "%s: expected size %ld, got %ld\n", name, cb, blob.cbData); - blob.pbData = HeapAlloc(GetProcessHeap(), 0, blob.cbData); + blob.pbData = malloc(blob.cbData); if (blob.pbData) { ret = CertSaveStore(store, X509_ASN_ENCODING, CERT_STORE_SAVE_AS_STORE, CERT_STORE_SAVE_TO_MEMORY, &blob, 0); - ok(ret, "CertSaveStore failed: %08x\n", GetLastError()); + ok(ret, "CertSaveStore failed: %08lx\n", GetLastError()); todo_wine_if (todo) ok(!memcmp(pb, blob.pbData, cb), "%s: unexpected value\n", name); - HeapFree(GetProcessHeap(), 0, blob.pbData); + free(blob.pbData); } } @@ -366,16 +364,6 @@ static const struct */ static void testRegStoreSavedCerts(void) { - static const WCHAR fmt[] = - { '%','s','\\','%','s','\\','%','s','\\','%','s',0}, - ms_certs[] = - { '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',0}, - certs[] = - {'C','e','r','t','i','f','i','c','a','t','e','s',0}, - bigCert_hash[] = { - '6','E','3','0','9','0','7','1','5','F','D','9','2','3', - '5','6','E','B','A','E','2','5','4','0','E','6','2','2', - 'D','A','1','9','2','6','0','2','A','6','0','8',0}; PCCERT_CONTEXT cert1, cert2; HCERTSTORE store; HANDLE cert_file; @@ -395,50 +383,50 @@ static void testRegStoreSavedCerts(void) err = GetLastError(); if (!store) { - ok (err == ERROR_ACCESS_DENIED, "Failed to create store at %d (%08x)\n", i, err); - skip("Insufficient privileges for the test %d\n", i); + ok (err == ERROR_ACCESS_DENIED, "Failed to create store at %ld (%08lx)\n", i, err); + skip("Insufficient privileges for the test %ld\n", i); continue; } - ok (store!=NULL, "Failed to open the store at %d, %x\n", i, GetLastError()); + ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError()); cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok (cert1 != NULL, "Create cert context failed at %d, %x\n", i, GetLastError()); + ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError()); ret = CertAddCertificateContextToStore(store, cert1, CERT_STORE_ADD_REPLACE_EXISTING, NULL); - /* Addittional skip per Win7, it allows opening HKLM store, but disallows adding certs */ + /* Additional skip per Win7, it allows opening HKLM store, but disallows adding certs */ err = GetLastError(); if (!ret) { - ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %d (%08x)\n", i, err); - skip("Insufficient privileges for the test %d\n", i); + ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %ld (%08lx)\n", i, err); + skip("Insufficient privileges for the test %ld\n", i); continue; } - ok (ret, "Adding to the store failed at %d, %x\n", i, err); + ok (ret, "Adding to the store failed at %ld, %lx\n", i, err); CertFreeCertificateContext(cert1); CertCloseStore(store, 0); - wsprintfW(key_name, fmt, reg_store_saved_certs[i].base_reg_path, - reg_store_saved_certs[i].store_name, certs, bigCert_hash); + wsprintfW(key_name, L"%s\\%s\\%s\\%s", reg_store_saved_certs[i].base_reg_path, + reg_store_saved_certs[i].store_name, L"Certificates", L"6E3090715FD92356EBAE2540E622DA192602A608"); if (!reg_store_saved_certs[i].appdata_file) { res = RegOpenKeyExW(reg_store_saved_certs[i].key, key_name, 0, KEY_ALL_ACCESS, &key); - ok (!res, "The cert hasn't been saved at %d, %x\n", i, GetLastError()); + ok (!res, "The cert hasn't been saved at %ld, %lx\n", i, GetLastError()); if (!res) RegCloseKey(key); } else { pathres = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, appdata_path); ok (pathres == S_OK, - "Failed to get app data path at %d (%x)\n", pathres, GetLastError()); + "Failed to get app data path at %ld (%lx)\n", pathres, GetLastError()); if (pathres == S_OK) { - PathAppendW(appdata_path, ms_certs); + PathAppendW(appdata_path, L"Microsoft\\SystemCertificates"); PathAppendW(appdata_path, reg_store_saved_certs[i].store_name); - PathAppendW(appdata_path, certs); - PathAppendW(appdata_path, bigCert_hash); + PathAppendW(appdata_path, L"Certificates"); + PathAppendW(appdata_path, L"6E3090715FD92356EBAE2540E622DA192602A608"); cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); todo_wine ok (cert_file != INVALID_HANDLE_VALUE, - "Cert was not saved in AppData at %d (%x)\n", i, GetLastError()); + "Cert was not saved in AppData at %ld (%lx)\n", i, GetLastError()); CloseHandle(cert_file); } } @@ -446,24 +434,24 @@ static void testRegStoreSavedCerts(void) /* deleting cert from store */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, reg_store_saved_certs[i].cert_store, reg_store_saved_certs[i].store_name); - ok (store!=NULL, "Failed to open the store at %d, %x\n", i, GetLastError()); + ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError()); cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok (cert1 != NULL, "Create cert context failed at %d, %x\n", i, GetLastError()); + ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError()); cert2 = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, CERT_FIND_EXISTING, cert1, NULL); - ok (cert2 != NULL, "Failed to find cert in the store at %d, %x\n", i, GetLastError()); + ok (cert2 != NULL, "Failed to find cert in the store at %ld, %lx\n", i, GetLastError()); ret = CertDeleteCertificateFromStore(cert2); - ok (ret, "Failed to delete certificate from store at %d, %x\n", i, GetLastError()); + ok (ret, "Failed to delete certificate from store at %ld, %lx\n", i, GetLastError()); CertFreeCertificateContext(cert1); CertFreeCertificateContext(cert2); CertCloseStore(store, 0); res = RegOpenKeyExW(reg_store_saved_certs[i].key, key_name, 0, KEY_ALL_ACCESS, &key); - ok (res, "The cert's registry entry should be absent at %i, %x\n", i, GetLastError()); + ok (res, "The cert's registry entry should be absent at %li, %lx\n", i, GetLastError()); if (!res) RegCloseKey(key); if (reg_store_saved_certs[i].appdata_file) @@ -471,7 +459,7 @@ static void testRegStoreSavedCerts(void) cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ok (cert_file == INVALID_HANDLE_VALUE, - "Cert should have been absent in AppData %d\n", i); + "Cert should have been absent in AppData %ld\n", i); CloseHandle(cert_file); } @@ -486,37 +474,34 @@ static void testStoresInCollection(void) { PCCERT_CONTEXT cert1, cert2, tcert1; HCERTSTORE collection, ro_store, rw_store, rw_store_2, tstore; - static const WCHAR WineTestRO_W[] = { 'W','i','n','e','T','e','s','t','_','R','O',0 }, - WineTestRW_W[] = { 'W','i','n','e','T','e','s','t','_','R','W',0 }, - WineTestRW2_W[]= { 'W','i','n','e','T','e','s','t','_','R','W','2',0 }; BOOL ret; collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(collection != NULL, "Failed to init collection store, last error %x\n", GetLastError()); + ok(collection != NULL, "Failed to init collection store, last error %lx\n", GetLastError()); /* Add read-only store to collection with very high priority*/ ro_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRO_W); - ok(ro_store != NULL, "Failed to init ro store %x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RO"); + ok(ro_store != NULL, "Failed to init ro store %lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, ro_store, 0, 1000); - ok (ret, "Failed to add read-only store to collection %x\n", GetLastError()); + ok (ret, "Failed to add read-only store to collection %lx\n", GetLastError()); cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok (cert1 != NULL, "Create cert context failed %x\n", GetLastError()); + ok (cert1 != NULL, "Create cert context failed %lx\n", GetLastError()); ret = CertAddCertificateContextToStore(collection, cert1, CERT_STORE_ADD_ALWAYS, NULL); - ok (!ret, "Added cert to collection with single read-only store %x\n", GetLastError()); + ok (!ret, "Added cert to collection with single read-only store %lx\n", GetLastError()); /* Add read-write store to collection with the lowest priority*/ rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW_W); - ok (rw_store != NULL, "Failed to open rw store %x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); + ok (rw_store != NULL, "Failed to open rw store %lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, rw_store, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok (ret, "Failed to add rw store to collection %x\n", GetLastError()); + ok (ret, "Failed to add rw store to collection %lx\n", GetLastError()); /** Adding certificate to collection should fall into rw store, * even though prioirty of the ro_store is higher */ ret = CertAddCertificateContextToStore(collection, cert1, CERT_STORE_ADD_REPLACE_EXISTING, NULL); - ok (ret, "Failed to add cert to the collection %x\n", GetLastError()); + ok (ret, "Failed to add cert to the collection %lx\n", GetLastError()); tcert1 = CertEnumCertificatesInStore(ro_store, NULL); ok (!tcert1, "Read-only ro_store contains cert\n"); @@ -533,15 +518,15 @@ static void testStoresInCollection(void) /** adding one more rw store with higher priority*/ rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW2_W); - ok (rw_store_2 != NULL, "Failed to init second rw store %x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2"); + ok (rw_store_2 != NULL, "Failed to init second rw store %lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, rw_store_2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 50); - ok (ret, "Failed to add rw_store_2 to collection %x\n",GetLastError()); + ok (ret, "Failed to add rw_store_2 to collection %lx\n",GetLastError()); cert2 = CertCreateCertificateContext(X509_ASN_ENCODING, signedBigCert, sizeof(signedBigCert)); - ok (cert2 != NULL, "Failed to create cert context %x\n", GetLastError()); + ok (cert2 != NULL, "Failed to create cert context %lx\n", GetLastError()); ret = CertAddCertificateContextToStore(collection, cert2, CERT_STORE_ADD_REPLACE_EXISTING, NULL); - ok (ret, "Failed to add cert2 to the store %x\n",GetLastError()); + ok (ret, "Failed to add cert2 to the store %lx\n",GetLastError()); /** checking certificates in the stores */ tcert1 = CertEnumCertificatesInStore(ro_store, 0); @@ -560,16 +545,16 @@ static void testStoresInCollection(void) /** checking certificates in the collection */ tcert1 = CertEnumCertificatesInStore(collection, NULL); ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded, - "cert2 expected in the collection got %p, %x\n",tcert1, GetLastError()); + "cert2 expected in the collection got %p, %lx\n",tcert1, GetLastError()); tcert1 = CertEnumCertificatesInStore(collection, tcert1); ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded, - "cert1 expected in the collection got %p, %x\n",tcert1, GetLastError()); + "cert1 expected in the collection got %p, %lx\n",tcert1, GetLastError()); tcert1 = CertEnumCertificatesInStore(collection, tcert1); - ok (tcert1==NULL,"Unexpected cert in the collection %p %x\n",tcert1, GetLastError()); + ok (tcert1==NULL,"Unexpected cert in the collection %p %lx\n",tcert1, GetLastError()); /* checking whether certs had been saved */ - tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, WineTestRW_W); + tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"WineTest_RW"); ok (tstore!=NULL, "Failed to open existing rw store\n"); tcert1 = CertEnumCertificatesInStore(tstore, NULL); todo_wine @@ -577,8 +562,8 @@ static void testStoresInCollection(void) CertFreeCertificateContext(tcert1); CertCloseStore(tstore,0); - tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, WineTestRW2_W); + tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"WineTest_RW2"); ok (tstore!=NULL, "Failed to open existing rw2 store\n"); tcert1 = CertEnumCertificatesInStore(tstore, NULL); todo_wine @@ -592,16 +577,16 @@ static void testStoresInCollection(void) CertCloseStore(rw_store_2,0); /* reopening registry stores to check whether certs had been saved */ - rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW_W); + rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); tcert1 = CertEnumCertificatesInStore(rw_store, NULL); ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded, "Unexpected cert in store %p\n", tcert1); CertFreeCertificateContext(tcert1); CertCloseStore(rw_store,0); - rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW2_W); + rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2"); tcert1 = CertEnumCertificatesInStore(rw_store_2, NULL); ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded, "Unexpected cert in store %p\n", tcert1); @@ -610,12 +595,12 @@ static void testStoresInCollection(void) CertFreeCertificateContext(cert1); CertFreeCertificateContext(cert2); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRO_W); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRW_W); - CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0, - CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,WineTestRW2_W); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RO"); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW"); + CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0, + CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2"); } @@ -624,8 +609,6 @@ static void testCollectionStore(void) HCERTSTORE store1, store2, collection, collection2; PCCERT_CONTEXT context; BOOL ret; - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HANDLE file; @@ -636,17 +619,17 @@ static void testCollectionStore(void) ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(!ret && GetLastError() == E_ACCESSDENIED, - "Expected E_ACCESSDENIED, got %08x\n", GetLastError()); + "Expected E_ACCESSDENIED, got %08lx\n", GetLastError()); /* Create and add a cert to a memory store */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* Add the memory store to the collection, without allowing adding */ ret = CertAddStoreToCollection(collection, store1, 0, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); /* Verify the cert is in the collection */ context = CertEnumCertificatesInStore(collection, NULL); ok(context != NULL, "Expected a valid context\n"); @@ -659,7 +642,7 @@ static void testCollectionStore(void) ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL); ok(!ret && GetLastError() == E_ACCESSDENIED, - "Expected E_ACCESSDENIED, got %08x\n", GetLastError()); + "Expected E_ACCESSDENIED, got %08lx\n", GetLastError()); /* Create a new memory store */ store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, @@ -668,7 +651,7 @@ static void testCollectionStore(void) ret = CertAddStoreToCollection(store1, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Try adding some bogus stores */ /* This crashes in Windows ret = pCertAddStoreToCollection(0, store2, @@ -677,7 +660,7 @@ static void testCollectionStore(void) /* This "succeeds"... */ ret = CertAddStoreToCollection(collection, 0, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); /* while this crashes. ret = pCertAddStoreToCollection(collection, 1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); @@ -686,11 +669,11 @@ static void testCollectionStore(void) /* Add it to the collection, this time allowing adding */ ret = CertAddStoreToCollection(collection, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); /* Check that adding to the collection is allowed */ ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* Now check that it was actually added to store2 */ context = CertEnumCertificatesInStore(store2, NULL); ok(context != NULL, "Expected a valid context\n"); @@ -708,7 +691,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -717,7 +700,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert2), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert2, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -732,7 +715,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -741,7 +724,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert2), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert2, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -754,7 +737,7 @@ static void testCollectionStore(void) CERT_STORE_CREATE_NEW_FLAG, NULL); ret = CertAddStoreToCollection(collection2, collection, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); /* check the contents of collection2 */ context = CertEnumCertificatesInStore(collection2, NULL); ok(context != NULL, "Expected a valid context\n"); @@ -762,7 +745,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection2, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection2, context); @@ -771,7 +754,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection2, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert2), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert2, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection2, context); @@ -797,25 +780,25 @@ static void testCollectionStore(void) /* Add the same cert to two memory stores, then put them in a collection */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store1 != 0, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store1 != 0, "CertOpenStore failed: %08lx\n", GetLastError()); store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store2 != 0, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store2 != 0, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertAddEncodedCertificateToStore(store2, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(collection != 0, "CertOpenStore failed: %08x\n", GetLastError()); + ok(collection != 0, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); ret = CertAddStoreToCollection(collection, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); /* Check that the collection has two copies of the same cert */ context = CertEnumCertificatesInStore(collection, NULL); @@ -824,7 +807,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -833,7 +816,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); context = CertEnumCertificatesInStore(collection, context); @@ -873,7 +856,7 @@ static void testCollectionStore(void) { ok(context->hCertStore == collection, "Unexpected store\n"); ok(context->cbCertEncoded == sizeof(bigCert), - "Wrong size %d\n", context->cbCertEncoded); + "Wrong size %ld\n", context->cbCertEncoded); ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded), "Unexpected cert\n"); } @@ -891,13 +874,13 @@ static void testCollectionStore(void) SetLastError(0xdeadbeef); CertRemoveStoreFromCollection(store2, collection); ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); + "Didn't expect an error to be set: %08lx\n", GetLastError()); /* After removing store2, the collection should be empty */ SetLastError(0xdeadbeef); CertRemoveStoreFromCollection(collection, store2); ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); + "Didn't expect an error to be set: %08lx\n", GetLastError()); context = CertEnumCertificatesInStore(collection, NULL); ok(!context, "Unexpected cert\n"); @@ -913,14 +896,14 @@ static void testCollectionStore(void) ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); CertDeleteCertificateFromStore(context); CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); CertDeleteCertificateFromStore(context); CertCloseStore(collection, 0); @@ -932,7 +915,7 @@ static void testCollectionStore(void) SetLastError(0xdeadbeef); ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* Adding a mem store that can't be committed prevents a successful commit. */ @@ -942,14 +925,14 @@ static void testCollectionStore(void) SetLastError(0xdeadbeef); ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError()); + "expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError()); CertRemoveStoreFromCollection(collection, store1); CertCloseStore(store1, 0); /* Test adding a cert to a collection with a file store, committing the * change to the collection, and comparing the resulting file. */ - if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return; DeleteFileW(filename); @@ -960,14 +943,14 @@ static void testCollectionStore(void) store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store1 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); CloseHandle(file); CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); CertCloseStore(store1, 0); ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %d\n", ret); @@ -1023,23 +1006,23 @@ static void testRegStore(void) store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, NULL); GLE = GetLastError(); ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY), - "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", GLE); + "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE); store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key); GLE = GetLastError(); ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY), - "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", GLE); + "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE); /* Opening up any old key works.. */ key = HKEY_CURRENT_USER; store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key); /* Not sure if this is a bug in DuplicateHandle, marking todo_wine for now */ - todo_wine ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + todo_wine ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); CertCloseStore(store, 0); rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL); - ok(!rc, "RegCreateKeyExA failed: %d\n", rc); + ok(!rc, "RegCreateKeyExA failed: %ld\n", rc); if (key) { BOOL ret; @@ -1051,40 +1034,40 @@ static void testRegStore(void) PCCERT_CONTEXT context; store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key); - ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); /* Add a certificate. It isn't persisted right away, since it's only * added to the cache.. */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* so flush the cache to force a commit.. */ ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* and check that the expected subkey was written. */ size = sizeof(hash); ret = CryptHashCertificate(0, 0, 0, bigCert2, sizeof(bigCert2), hash, &size); - ok(ret, "CryptHashCertificate failed: %d\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError()); strcpy(subKeyName, certificates); for (i = 0, ptr = subKeyName + sizeof(certificates) - 1; i < size; i++, ptr += 2) sprintf(ptr, "%02X", hash[i]); rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &subKey, NULL); - ok(!rc, "RegCreateKeyExA failed: %d\n", rc); + ok(!rc, "RegCreateKeyExA failed: %ld\n", rc); if (subKey) { LPBYTE buf; size = 0; RegQueryValueExA(subKey, "Blob", NULL, NULL, NULL, &size); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { rc = RegQueryValueExA(subKey, "Blob", NULL, NULL, buf, &size); - ok(!rc, "RegQueryValueExA failed: %d\n", rc); + ok(!rc, "RegQueryValueExA failed: %ld\n", rc); if (!rc) { const struct CertPropIDHeader *hdr; @@ -1095,7 +1078,7 @@ static void testRegStore(void) if (hdr) { ok(hdr->cb == sizeof(bigCert2), - "Wrong size %d of cert property\n", hdr->cb); + "Wrong size %ld of cert property\n", hdr->cb); ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), bigCert2, hdr->cb), "Unexpected cert in cert property\n"); } @@ -1104,12 +1087,12 @@ static void testRegStore(void) if (hdr) { ok(hdr->cb == sizeof(hash), - "Wrong size %d of hash property\n", hdr->cb); + "Wrong size %ld of hash property\n", hdr->cb); ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), hash, hdr->cb), "Unexpected hash in cert property\n"); } } - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } RegCloseKey(subKey); } @@ -1120,7 +1103,7 @@ static void testRegStore(void) if (context) CertDeleteCertificateFromStore(context); ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* Add a serialized cert with a bogus hash directly to the registry */ memset(hash, 0, sizeof(hash)); @@ -1130,7 +1113,7 @@ static void testRegStore(void) sprintf(ptr, "%02X", hash[i]); rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &subKey, NULL); - ok(!rc, "RegCreateKeyExA failed: %d\n", rc); + ok(!rc, "RegCreateKeyExA failed: %ld\n", rc); if (subKey) { BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) + @@ -1154,10 +1137,10 @@ static void testRegStore(void) rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf, sizeof(buf)); - ok(!rc, "RegSetValueExA failed: %d\n", rc); + ok(!rc, "RegSetValueExA failed: %ld\n", rc); ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* Make sure the bogus hash cert gets loaded. */ certCount = 0; @@ -1167,7 +1150,7 @@ static void testRegStore(void) if (context) certCount++; } while (context != NULL); - ok(certCount == 1, "Expected 1 certificates, got %d\n", certCount); + ok(certCount == 1, "Expected 1 certificates, got %ld\n", certCount); RegCloseKey(subKey); } @@ -1178,14 +1161,14 @@ static void testRegStore(void) size = sizeof(hash); ret = CryptHashCertificate(0, 0, 0, bigCert2, sizeof(bigCert2), hash, &size); - ok(ret, "CryptHashCertificate failed: %d\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError()); strcpy(subKeyName, certificates); for (i = 0, ptr = subKeyName + sizeof(certificates) - 1; i < sizeof(hash); i++, ptr += 2) sprintf(ptr, "%02X", hash[i]); rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &subKey, NULL); - ok(!rc, "RegCreateKeyExA failed: %d\n", rc); + ok(!rc, "RegCreateKeyExA failed: %ld\n", rc); if (subKey) { BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) + @@ -1211,10 +1194,10 @@ static void testRegStore(void) rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf, sizeof(buf)); - ok(!rc, "RegSetValueExA failed: %d\n", rc); + ok(!rc, "RegSetValueExA failed: %ld\n", rc); ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* and make sure just one cert still gets loaded. */ certCount = 0; @@ -1224,7 +1207,7 @@ static void testRegStore(void) if (context) certCount++; } while (context != NULL); - ok(certCount == 1, "Expected 1 certificate, got %d\n", certCount); + ok(certCount == 1, "Expected 1 certificate, got %ld\n", certCount); /* Try again with the correct hash... */ ptr = buf + sizeof(*hdr); @@ -1232,10 +1215,10 @@ static void testRegStore(void) rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf, sizeof(buf)); - ok(!rc, "RegSetValueExA failed: %d\n", rc); + ok(!rc, "RegSetValueExA failed: %ld\n", rc); ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); - ok(ret, "CertControlStore failed: %08x\n", GetLastError()); + ok(ret, "CertControlStore failed: %08lx\n", GetLastError()); /* and make sure two certs get loaded. */ certCount = 0; @@ -1245,7 +1228,7 @@ static void testRegStore(void) if (context) certCount++; } while (context != NULL); - ok(certCount == 2, "Expected 2 certificates, got %d\n", certCount); + ok(certCount == 2, "Expected 2 certificates, got %ld\n", certCount); RegCloseKey(subKey); } @@ -1254,7 +1237,7 @@ static void testRegStore(void) store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, CERT_STORE_DELETE_FLAG, key); ok(store == NULL, "Expected NULL return from CERT_STORE_DELETE_FLAG\n"); - ok(GetLastError() == 0, "CertOpenStore failed: %08x\n", + ok(GetLastError() == 0, "CertOpenStore failed: %08lx\n", GetLastError()); RegCloseKey(key); @@ -1264,9 +1247,9 @@ static void testRegStore(void) */ rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, &disp); - ok(!rc, "RegCreateKeyExA failed: %d\n", rc); + ok(!rc, "RegCreateKeyExA failed: %ld\n", rc); ok(disp == REG_OPENED_EXISTING_KEY, - "Expected REG_OPENED_EXISTING_KEY, got %d\n", disp); + "Expected REG_OPENED_EXISTING_KEY, got %ld\n", disp); if (!rc) { RegCloseKey(key); @@ -1281,20 +1264,13 @@ static void testRegStore(void) } } -static const char MyA[] = { 'M','y',0,0 }; -static const WCHAR MyW[] = { 'M','y',0 }; -static const WCHAR BogusW[] = { 'B','o','g','u','s',0 }; -static const WCHAR BogusPathW[] = { 'S','o','f','t','w','a','r','e','\\', - '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','\\','B','o','g','u','s',0 }; - static void testSystemRegStore(void) { HCERTSTORE store, memStore; /* Check with a UNICODE name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"My"); /* Not all OSes support CERT_STORE_PROV_SYSTEM_REGISTRY, so don't continue * testing if they don't. */ @@ -1307,48 +1283,47 @@ static void testSystemRegStore(void) if (memStore) { BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0); - ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); + ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError()); CertCloseStore(memStore, 0); } CertCloseStore(store, 0); /* Check opening a bogus store */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"Bogus"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, BogusW); - ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"Bogus"); + ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Now check whether deleting is allowed */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); - ok(!store, "CertOpenStore failed: %08x\n", GetLastError()); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); + ok(!store, "CertOpenStore failed: %08lx\n", GetLastError()); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus"); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, 0, NULL); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, "My"); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, L"My"); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* The name is expected to be UNICODE, check with an ASCII name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); } static void testSystemStore(void) { - static const WCHAR baskslashW[] = { '\\',0 }; HCERTSTORE store; WCHAR keyName[MAX_PATH]; HKEY key; @@ -1356,38 +1331,37 @@ static void testSystemStore(void) store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, 0, NULL); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW); + CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, L"My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* The name is expected to be UNICODE, first check with an ASCII name */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My"); ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Create the expected key */ lstrcpyW(keyName, CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH); - lstrcatW(keyName, baskslashW); - lstrcatW(keyName, MyW); + lstrcatW(keyName, L"\\My"); rc = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_READ, NULL, &key, NULL); - ok(!rc, "RegCreateKeyEx failed: %d\n", rc); + ok(!rc, "RegCreateKeyEx failed: %ld\n", rc); if (!rc) RegCloseKey(key); /* Check opening with a UNICODE name, specifying the create new flag */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_CREATE_NEW_FLAG, MyW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_CREATE_NEW_FLAG, L"My"); ok(!store && GetLastError() == ERROR_FILE_EXISTS, - "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError()); + "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError()); /* Now check opening with a UNICODE name, this time opening existing */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyW); - ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"My"); + ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { HCERTSTORE memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, @@ -1397,7 +1371,7 @@ static void testSystemStore(void) if (memStore) { BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0); - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError()); CertCloseStore(memStore, 0); } CertCloseStore(store, 0); @@ -1405,18 +1379,18 @@ static void testSystemStore(void) /* Check opening a bogus store */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW); - ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, L"Bogus"); + ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, BogusW); - ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"Bogus"); + ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Now check whether deleting is allowed */ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); ok(!store, "Didn't expect a store to be returned when deleting\n"); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus"); } static const BYTE serializedStoreWithCertAndCRL[] = { @@ -1439,8 +1413,6 @@ static const BYTE serializedStoreWithCertAndCRL[] = { static void testFileStore(void) { - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HCERTSTORE store; BOOL ret; @@ -1449,9 +1421,9 @@ static void testFileStore(void) store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL); ok(!store && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_HANDLE, got %08lx\n", GetLastError()); - if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return; DeleteFileW(filename); @@ -1463,16 +1435,16 @@ static void testFileStore(void) store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_STORE_DELETE_FLAG, file); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_READONLY_FLAG, file); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* A "read-only" file store.. */ store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, file); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { DWORD size; @@ -1484,22 +1456,22 @@ static void testFileStore(void) /* but not commits.. */ ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); + "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError()); /* It still has certs in memory.. */ cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); CertFreeCertificateContext(cert); /* but the file size is still 0. */ size = GetFileSize(file, NULL); - ok(size == 0, "Expected size 0, got %d\n", size); + ok(size == 0, "Expected size 0, got %ld\n", size); CertCloseStore(store, 0); } /* The create new flag is allowed.. */ store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_STORE_CREATE_NEW_FLAG, file); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { /* but without the commit enable flag, commits don't happen. */ @@ -1508,13 +1480,13 @@ static void testFileStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); + "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError()); CertCloseStore(store, 0); } /* as is the open existing flag. */ store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG, file); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { /* but without the commit enable flag, commits don't happen. */ @@ -1523,18 +1495,18 @@ static void testFileStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); + "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError()); CertCloseStore(store, 0); } store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { CloseHandle(file); ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* with commits enabled, commit is allowed */ ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); @@ -1549,13 +1521,13 @@ static void testFileStore(void) return; store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { CloseHandle(file); ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); compareStore(store, "serialized store with cert and CRL", serializedStoreWithCertAndCRL, sizeof(serializedStoreWithCertAndCRL), FALSE); @@ -1597,57 +1569,22 @@ static const BYTE base64SPC[] = "G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu" "y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA=="; /* Same as base64SPC, but as a wide-char string */ -static const WCHAR utf16Base64SPC[] = { -'M','I','I','C','J','Q','Y','J','K','o','Z','I','h','v','c','N','A', -'Q','c','C','o','I','I','C','F','j','C','C','A','h','I','C','A','Q', -'E','x','A','D','A','L','B','g','k','q','h','k','i','G','9','w','0', -'B','B','w','G','g','g','g','H','6','M','I','I','B','9','j','C','C', -'A','V','+','g','A','w','I','B','A','g','I','Q','n','P','8','+','E', -'F','4','o','p','r','9','O','x','H','7','h','4','u','B','P','W','T', -'A','N','B','g','k','q','h','k','i','G','9','w','0','B','A','Q','Q', -'F','A','D','A','U','M','R','I','w','E','A','Y','D','V','Q','Q','D', -'E','w','l','K','d','W','F','u','I','E','x','h','b','m','c','w','H', -'h','c','N','M','D','g','x','M','j','E','y','M','T','c','x','M','D', -'E','0','W','h','c','N','M','z','k','x','M','j','M','x','M','j','M', -'1','O','T','U','5','W','j','A','U','M','R','I','w','E','A','Y','D', -'V','Q','Q','D','E','w','l','K','d','W','F','u','I','E','x','h','b', -'m','c','w','g','Z','8','w','D','Q','Y','J','K','o','Z','I','h','v', -'c','N','A','Q','E','B','B','Q','A','D','g','Y','0','A','M','I','G', -'J','A','o','G','B','A','L','C','g','N','j','y','N','v','O','i','c', -'0','F','O','f','j','x','v','i','4','3','H','b','M','+','D','5','j', -'o','D','k','h','i','G','S','X','e','+','g','b','Z','l','f','8','f', -'1','6','k','0','7','k','k','O','b','F','E','u','n','z','m','d','B', -'5','c','o','s','c','m','A','7','g','y','q','i','W','N','N','4','Z', -'U','y','r','2','c','A','3','l','C','b','n','p','G','P','A','/','0', -'I','b','l','y','y','O','c','u','G','I','F','m','m','C','z','e','Z', -'a','V','a','5','Z','G','6','x','Z','P','K','7','L','7','o','+','7', -'3','Q','o','6','j','X','V','b','G','h','B','G','n','M','Z','7','Q', -'9','s','A','n','6','s','2','9','3','3','o','l','n','S','t','n','e', -'j','n','q','w','V','0','N','A','g','M','B','A','A','G','j','S','T', -'B','H','M','E','U','G','A','1','U','d','A','Q','Q','+','M','D','y', -'A','E','F','K','b','K','E','d','X','Y','y','x','+','C','W','K','c', -'V','6','v','x','M','6','S','h','F','j','A','U','M','R','I','w','E', -'A','Y','D','V','Q','Q','D','E','w','l','K','d','W','F','u','I','E', -'x','h','b','m','e','C','E','J','z','/','P','h','B','e','K','K','a', -'/','T','s','R','+','4','e','L','g','T','1','k','w','D','Q','Y','J', -'K','o','Z','I','h','v','c','N','A','Q','E','E','B','Q','A','D','g', -'Y','E','A','L','p','k','g','L','g','W','3','m','E','a','K','i','d', -'P','Q','3','i','P','J','Y','L','G','0','U','b','1','w','r','a','q', -'E','l','9','b','d','4','2','h','r','h','z','I','d','c','D','z','l', -'Q','g','x','n','m','8','/','5','c','H','Y','V','x','I','F','/','C', -'2','0','x','/','H','J','p','l','b','1','R','G','6','U','1','i','p', -'F','e','/','q','8','b','y','W','D','/','9','J','p','i','B','K','M', -'G','P','i','9','Y','l','U','T','g','X','H','f','S','9','d','4','S', -'/','Q','W','O','1','h','9','Z','7','K','e','i','p','B','Y','h','o', -'s','l','Q','p','H','X','u','y','9','b','U','r','8','A','d','q','i', -'6','S','z','g','H','p','C','n','M','u','5','3','d','x','g','x','U', -'D','1','r','4','x','A','A','=','=',0 }; +static const WCHAR utf16Base64SPC[] = +L"MIICJQYJKoZIhvcNAQcCoIICFjCCAhICAQExADALBgkqhkiG9w0BBwGgggH6MIIB" +"9jCCAV+gAwIBAgIQnP8+EF4opr9OxH7h4uBPWTANBgkqhkiG9w0BAQQFADAUMRIw" +"EAYDVQQDEwlKdWFuIExhbmcwHhcNMDgxMjEyMTcxMDE0WhcNMzkxMjMxMjM1OTU5" +"WjAUMRIwEAYDVQQDEwlKdWFuIExhbmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ" +"AoGBALCgNjyNvOic0FOfjxvi43HbM+D5joDkhiGSXe+gbZlf8f16k07kkObFEunz" +"mdB5coscmA7gyqiWNN4ZUyr2cA3lCbnpGPA/0IblyyOcuGIFmmCzeZaVa5ZG6xZP" +"K7L7o+73Qo6jXVbGhBGnMZ7Q9sAn6s2933olnStnejnqwV0NAgMBAAGjSTBHMEUG" +"A1UdAQQ+MDyAEFKbKEdXYyx+CWKcV6vxM6ShFjAUMRIwEAYDVQQDEwlKdWFuIExh" +"bmeCEJz/PhBeKKa/TsR+4eLgT1kwDQYJKoZIhvcNAQEEBQADgYEALpkgLgW3mEaK" +"idPQ3iPJYLG0Ub1wraqEl9bd42hrhzIdcDzlQgxnm8/5cHYVxIF/C20x/HJplb1R" +"G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu" +"y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA=="; static void testFileNameStore(void) { - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR spcPrefix[] = { 's','p','c',0 }; - static const WCHAR szDot[] = { '.',0 }; WCHAR filename[MAX_PATH]; HCERTSTORE store; BOOL ret; @@ -1656,10 +1593,10 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL); GLE = GetLastError(); ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER), - "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n", + "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08lx\n", GLE); - if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"cer", 0, filename)) return; DeleteFileW(filename); @@ -1667,7 +1604,7 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_READONLY_FLAG, filename); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* In all of the following tests, the encoding type seems to be ignored */ if (initFileFromData(filename, bigCert, sizeof(bigCert))) @@ -1677,10 +1614,10 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); @@ -1698,10 +1635,10 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); @@ -1719,15 +1656,15 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); crl = CertEnumCRLsInStore(store, NULL); - ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError()); + ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n", GetLastError()); crl = CertEnumCRLsInStore(store, crl); ok(!crl, "Expected only one CRL\n"); @@ -1737,18 +1674,18 @@ static void testFileNameStore(void) /* Now that the file exists, we can open it read-only */ store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); CertCloseStore(store, 0); DeleteFileW(filename); store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_CREATE_NEW_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); compareStore(store, "serialized store with cert", serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE); @@ -1756,12 +1693,12 @@ static void testFileNameStore(void) } store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError()); compareStore(store, "serialized store with cert and CRL", serializedStoreWithCertAndCRL, sizeof(serializedStoreWithCertAndCRL), FALSE); @@ -1769,7 +1706,7 @@ static void testFileNameStore(void) } DeleteFileW(filename); - if (!GetTempFileNameW(szDot, spcPrefix, 0, filename)) + if (!GetTempFileNameW(L".", L"spc", 0, filename)) return; DeleteFileW(filename); @@ -1780,10 +1717,10 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); @@ -1801,10 +1738,10 @@ static void testFileNameStore(void) store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, CERT_STORE_READONLY_FLAG, filename); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); @@ -1882,10 +1819,10 @@ static void testMessageStore(void) SetLastError(0xdeadbeef); store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg); ok(!store && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE); store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { PCCERT_CONTEXT cert = NULL; @@ -1897,7 +1834,7 @@ static void testMessageStore(void) if (cert) count++; } while (cert); - ok(count == 0, "Expected 0 certificates, got %d\n", count); + ok(count == 0, "Expected 0 certificates, got %ld\n", count); count = 0; do { @@ -1905,12 +1842,12 @@ static void testMessageStore(void) if (crl) count++; } while (crl); - ok(count == 0, "Expected 0 CRLs, got %d\n", count); + ok(count == 0, "Expected 0 CRLs, got %ld\n", count); /* Can add certs to a message store */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); count = 0; do { @@ -1918,22 +1855,22 @@ static void testMessageStore(void) if (cert) count++; } while (cert); - ok(count == 1, "Expected 1 certificate, got %d\n", count); + ok(count == 1, "Expected 1 certificate, got %ld\n", count); CertCloseStore(store, 0); } /* but the added certs weren't actually added to the message */ size = sizeof(count); ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &count, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(count == 0, "Expected 0 certificates, got %d\n", count); + ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError()); + ok(count == 0, "Expected 0 certificates, got %ld\n", count); CryptMsgClose(msg); /* Crashes store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, NULL); */ store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { DWORD count = 0; @@ -1945,7 +1882,7 @@ static void testMessageStore(void) if (cert) count++; } while (cert); - ok(count == 1, "Expected 1 certificate, got %d\n", count); + ok(count == 1, "Expected 1 certificate, got %ld\n", count); count = 0; do { @@ -1953,14 +1890,14 @@ static void testMessageStore(void) if (crl) count++; } while (crl); - ok(count == 1, "Expected 1 CRL, got %d\n", count); + ok(count == 1, "Expected 1 CRL, got %ld\n", count); CertCloseStore(store, 0); } /* Encoding appears to be ignored */ store = CertOpenStore(CERT_STORE_PROV_PKCS7, X509_ASN_ENCODING, 0, 0, &blob); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Messages other than signed messages aren't allowed */ @@ -1969,13 +1906,13 @@ static void testMessageStore(void) SetLastError(0xdeadbeef); store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob); ok(!store && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, - "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError()); blob.cbData = sizeof(hashBareContent); blob.pbData = (LPBYTE)hashBareContent; SetLastError(0xdeadbeef); store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob); ok(!store && GetLastError() == CRYPT_E_ASN1_BADTAG, - "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); + "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError()); } static void testSerializedStore(void) @@ -1995,16 +1932,16 @@ static void testSerializedStore(void) store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, CERT_STORE_DELETE_FLAG, &blob); ok(!store && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, - "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); + "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { PCCERT_CONTEXT cert; PCCRL_CONTEXT crl; cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); @@ -2016,19 +1953,19 @@ static void testSerializedStore(void) blob.cbData = sizeof(serializedStoreWithCertAndCRL); blob.pbData = (BYTE *)serializedStoreWithCertAndCRL; store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob); - ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); if (store) { PCCERT_CONTEXT cert; PCCRL_CONTEXT crl; cert = CertEnumCertificatesInStore(store, NULL); - ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n", + ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n", GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); crl = CertEnumCRLsInStore(store, NULL); - ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", + ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n", GetLastError()); crl = CertEnumCRLsInStore(store, crl); ok(!crl, "Expected only one CRL\n"); @@ -2043,18 +1980,18 @@ static void testCertOpenSystemStore(void) store = CertOpenSystemStoreW(0, NULL); ok(!store && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* This succeeds, and on WinXP at least, the Bogus key is created under * HKCU (but not under HKLM, even when run as an administrator.) */ - store = CertOpenSystemStoreW(0, BogusW); - ok(store != 0, "CertOpenSystemStore failed: %08x\n", GetLastError()); + store = CertOpenSystemStoreW(0, L"Bogus"); + ok(store != 0, "CertOpenSystemStore failed: %08lx\n", GetLastError()); if (store) CertCloseStore(store, 0); /* Delete it so other tests succeed next time around */ CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW); - RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); + RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus"); } static const struct @@ -2077,13 +2014,12 @@ static void testCertRegisterSystemStore(void) BOOL ret, cur_flag; DWORD err = 0; HCERTSTORE hstore; - static const WCHAR WineTestW[] = {'W','i','n','e','T','e','s','t',0}; const CERT_CONTEXT *cert, *cert2; unsigned int i; for (i = 0; i < ARRAY_SIZE(reg_system_store_test_data); i++) { cur_flag = reg_system_store_test_data[i].cert_store; - ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL); + ret = CertRegisterSystemStore(L"WineTest", cur_flag, NULL, NULL); if (!ret) { err = GetLastError(); @@ -2095,40 +2031,40 @@ static void testCertRegisterSystemStore(void) } todo_wine_if (reg_system_store_test_data[i].todo) ok (ret == reg_system_store_test_data[i].expected, - "Store registration (dwFlags=%08x) failed, last error %x\n", cur_flag, err); + "Store registration (dwFlags=%08x) failed, last error %lx\n", cur_flag, err); if (!ret) { skip("Nothing to test without registered store at %08x\n", cur_flag); continue; } - hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, WineTestW); - ok (hstore != NULL, "Opening just registered store at %08x failed, last error %x\n", cur_flag, GetLastError()); + hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, L"WineTest"); + ok (hstore != NULL, "Opening just registered store at %08x failed, last error %lx\n", cur_flag, GetLastError()); cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ok (cert != NULL, "Failed creating cert at %08x, last error: %x\n", cur_flag, GetLastError()); + ok (cert != NULL, "Failed creating cert at %08x, last error: %lx\n", cur_flag, GetLastError()); if (cert) { ret = CertAddCertificateContextToStore(hstore, cert, CERT_STORE_ADD_NEW, NULL); - ok (ret, "Failed to add cert at %08x, last error: %x\n", cur_flag, GetLastError()); + ok (ret, "Failed to add cert at %08x, last error: %lx\n", cur_flag, GetLastError()); cert2 = CertEnumCertificatesInStore(hstore, NULL); ok (cert2 != NULL && cert2->cbCertEncoded == cert->cbCertEncoded, - "Unexpected cert encoded size at %08x, last error: %x\n", cur_flag, GetLastError()); + "Unexpected cert encoded size at %08x, last error: %lx\n", cur_flag, GetLastError()); ret = CertDeleteCertificateFromStore(cert2); - ok (ret, "Failed to delete certificate from the new store at %08x, last error: %x\n", cur_flag, GetLastError()); + ok (ret, "Failed to delete certificate from the new store at %08x, last error: %lx\n", cur_flag, GetLastError()); CertFreeCertificateContext(cert); } ret = CertCloseStore(hstore, 0); - ok (ret, "CertCloseStore failed at %08x, last error %x\n", cur_flag, GetLastError()); + ok (ret, "CertCloseStore failed at %08x, last error %lx\n", cur_flag, GetLastError()); - ret = CertUnregisterSystemStore(WineTestW, cur_flag ); + ret = CertUnregisterSystemStore(L"WineTest", cur_flag ); todo_wine_if (reg_system_store_test_data[i].todo) ok( ret == reg_system_store_test_data[i].expected, - "Unregistering failed at %08x, last error %d\n", cur_flag, GetLastError()); + "Unregistering failed at %08x, last error %ld\n", cur_flag, GetLastError()); } } @@ -2156,7 +2092,7 @@ static void testCertEnumSystemStore(void) SetLastError(0xdeadbeef); ret = CertEnumSystemStore(0, NULL, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); /* Crashes ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL, NULL); @@ -2174,7 +2110,7 @@ static void testCertEnumSystemStore(void) info.storeCount = 0; ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, enumSystemStoreCB); - ok(ret, "CertEnumSystemStore failed: %08x\n", GetLastError()); + ok(ret, "CertEnumSystemStore failed: %08lx\n", GetLastError()); /* There should always be at least My, Root, and CA stores */ ok(info.storeCount == 0 || info.storeCount >= 3, "Expected at least 3 stores\n"); @@ -2199,11 +2135,11 @@ static void testStoreProperty(void) SetLastError(0xdeadbeef); ret = CertGetStoreProperty(store, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */ size = sizeof(state); ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); - ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", + ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n", GetLastError()); ok(!state, "Expected a non-persisted store\n"); /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */ @@ -2211,37 +2147,37 @@ static void testStoreProperty(void) ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); /* Delete an arbitrary property on a store */ ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); - ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError()); /* Set an arbitrary property on a store */ blob.pbData = (LPBYTE)&state; blob.cbData = sizeof(state); ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob); - ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError()); /* Get an arbitrary property that's been set */ ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); - ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); - ok(size == sizeof(state), "Unexpected data size %d\n", size); + ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError()); + ok(size == sizeof(state), "Unexpected data size %ld\n", size); ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size); - ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); + ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError()); ok(propID == state, "CertGetStoreProperty got the wrong value\n"); /* Delete it again */ ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); - ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); + ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError()); /* And check that it's missing */ SetLastError(0xdeadbeef); ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); CertCloseStore(store, 0); /* Recheck on the My store.. */ - store = CertOpenSystemStoreW(0, MyW); + store = CertOpenSystemStoreW(0, L"My"); size = sizeof(state); ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); - ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", + ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n", GetLastError()); ok(state, "Expected a persisted store\n"); SetLastError(0xdeadbeef); @@ -2249,7 +2185,7 @@ static void testStoreProperty(void) ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, - "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); + "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError()); CertCloseStore(store, 0); } @@ -2265,15 +2201,15 @@ static void testAddSerialized(void) ret = CertAddSerializedElementToStore(0, NULL, 0, 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_END_OF_MEDIA, - "Expected ERROR_END_OF_MEDIA, got %08x\n", GetLastError()); + "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, NULL, 0, 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_END_OF_MEDIA, - "Expected ERROR_END_OF_MEDIA, got %08x\n", GetLastError()); + "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError()); /* Test with an empty property */ hdr = (struct CertPropIDHeader *)buf; @@ -2283,71 +2219,71 @@ static void testAddSerialized(void) ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Test with a bad size in property header */ hdr->cb = sizeof(bigCert) - 1; memcpy(buf + sizeof(struct CertPropIDHeader), bigCert, sizeof(bigCert)); ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Kosher size in property header, but no context type */ hdr->cb = sizeof(bigCert); ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW, 0, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* With a bad context type */ ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW, 0, CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + "Expected E_INVALIDARG, got %08lx\n", GetLastError()); /* Bad unknown field, good type */ hdr->unknown1 = 2; ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError()); ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError()); /* Most everything okay, but bad add disposition */ hdr->unknown1 = 1; /* This crashes @@ -2361,13 +2297,13 @@ static void testAddSerialized(void) /* Everything okay, but buffer's too big */ ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL); - ok(ret, "CertAddSerializedElementToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError()); /* Everything okay, check it's not re-added */ ret = CertAddSerializedElementToStore(store, buf, sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_EXISTS, - "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError()); + "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError()); context = CertEnumCertificatesInStore(store, NULL); ok(context != NULL, "Expected a cert\n"); @@ -2387,7 +2323,7 @@ static void testAddSerialized(void) ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, (const void **)&context); - ok(ret, "CertAddSerializedElementToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError()); if (context) { BYTE hashVal[20], realHash[20]; @@ -2395,10 +2331,10 @@ static void testAddSerialized(void) ret = CryptHashCertificate(0, 0, 0, bigCert, sizeof(bigCert), realHash, &size); - ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError()); ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID, hashVal, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); ok(!memcmp(hashVal, realHash, size), "Unexpected hash\n"); CertFreeCertificateContext(context); @@ -2452,16 +2388,13 @@ static const BYTE serializedStoreWithCertAndHash[] = { static void delete_test_key(void) { HKEY root_key, test_key; - static const WCHAR SysCertW[] = {'S','o','f','t','w','a','r','e','\\','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',0}; - static const WCHAR WineTestW[] = {'W','i','n','e','T','e','s','t',0}; WCHAR subkey_name[32]; DWORD num_subkeys, subkey_name_len; int idx; - if (RegOpenKeyExW(HKEY_CURRENT_USER, SysCertW, 0, KEY_READ, &root_key)) + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates", 0, KEY_READ, &root_key)) return; - if (RegOpenKeyExW(root_key, WineTestW, 0, KEY_READ, &test_key)) + if (RegOpenKeyExW(root_key, L"WineTest", 0, KEY_READ, &test_key)) { RegCloseKey(root_key); return; @@ -2474,7 +2407,7 @@ static void delete_test_key(void) RegDeleteKeyW(test_key, subkey_name); } RegCloseKey(test_key); - RegDeleteKeyW(root_key, WineTestW); + RegDeleteKeyW(root_key, L"WineTest"); RegCloseKey(root_key); } @@ -2486,9 +2419,6 @@ static void testAddCertificateLink(void) DWORD size; LPBYTE buf; CERT_NAME_BLOB blob; - static const WCHAR szPrefix[] = { 'c','e','r',0 }; - static const WCHAR szDot[] = { '.',0 }; - static const WCHAR WineTestW[] = { 'W','i','n','e','T','e','s','t',0 }; WCHAR filename1[MAX_PATH], filename2[MAX_PATH]; HANDLE file; @@ -2504,16 +2434,16 @@ static void testAddCertificateLink(void) SetLastError(0xdeadbeef); ret = CertAddCertificateLinkToStore(store1, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); SetLastError(0xdeadbeef); ret = CertAddCertificateLinkToStore(store1, source, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, NULL); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (0) { /* Crashes, i.e. the source certificate is dereferenced without @@ -2528,49 +2458,49 @@ static void testAddCertificateLink(void) CERT_STORE_CREATE_NEW_FLAG, NULL); ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, &linked); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (ret) { ok(linked->hCertStore == store1, "unexpected store\n"); ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertSerializeCertificateStoreElement(linked, 0, buf, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); /* The serialized linked certificate is identical to the serialized * original certificate. */ - ok(size == sizeof(serializedCert), "Wrong size %d\n", size); + ok(size == sizeof(serializedCert), "Wrong size %ld\n", size); ok(!memcmp(serializedCert, buf, size), "Unexpected serialized cert\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* Set a friendly name on the source certificate... */ - blob.pbData = (LPBYTE)WineTestW; - blob.cbData = sizeof(WineTestW); + blob.pbData = (LPBYTE)L"WineTest"; + blob.cbData = sizeof(L"WineTest"); ret = CertSetCertificateContextProperty(source, CERT_FRIENDLY_NAME_PROP_ID, 0, &blob); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); /* and the linked certificate has the same friendly name. */ ret = CertGetCertificateContextProperty(linked, CERT_FRIENDLY_NAME_PROP_ID, NULL, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertGetCertificateContextProperty(linked, CERT_FRIENDLY_NAME_PROP_ID, buf, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(!lstrcmpW((LPCWSTR)buf, WineTestW), + ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"), "unexpected friendly name\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } CertFreeCertificateContext(linked); } @@ -2580,7 +2510,7 @@ static void testAddCertificateLink(void) /* Test adding a cert to a file store, committing the change to the store, * and creating a link to the resulting cert. */ - if (!GetTempFileNameW(szDot, szPrefix, 0, filename1)) + if (!GetTempFileNameW(L".", L"cer", 0, filename1)) return; DeleteFileW(filename1); @@ -2591,12 +2521,12 @@ static void testAddCertificateLink(void) store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store1 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); CloseHandle(file); ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &source); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); /* Test adding a link to a memory store. */ @@ -2604,53 +2534,53 @@ static void testAddCertificateLink(void) CERT_STORE_CREATE_NEW_FLAG, NULL); ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (ret) { ok(linked->hCertStore == store2, "unexpected store\n"); ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertSerializeCertificateStoreElement(linked, 0, buf, &size); /* The serialized linked certificate is identical to the serialized * original certificate. */ - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", GetLastError()); - ok(size == sizeof(serializedCert), "Wrong size %d\n", size); + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); + ok(size == sizeof(serializedCert), "Wrong size %ld\n", size); ok(!memcmp(serializedCert, buf, size), "Unexpected serialized cert\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } /* Set a friendly name on the source certificate... */ - blob.pbData = (LPBYTE)WineTestW; - blob.cbData = sizeof(WineTestW); + blob.pbData = (LPBYTE)L"WineTest"; + blob.cbData = sizeof(L"WineTest"); ret = CertSetCertificateContextProperty(source, CERT_FRIENDLY_NAME_PROP_ID, 0, &blob); - ok(ret, "CertSetCertificateContextProperty failed: %08x\n", + ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError()); /* and the linked certificate has the same friendly name. */ ret = CertGetCertificateContextProperty(linked, CERT_FRIENDLY_NAME_PROP_ID, NULL, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertGetCertificateContextProperty(linked, CERT_FRIENDLY_NAME_PROP_ID, buf, &size); - ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError()); - ok(!lstrcmpW((LPCWSTR)buf, WineTestW), + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); + ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"), "unexpected friendly name\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } CertFreeCertificateContext(linked); } CertCloseStore(store2, 0); - if (!GetTempFileNameW(szDot, szPrefix, 0, filename2)) + if (!GetTempFileNameW(L".", L"cer", 0, filename2)) return; DeleteFileW(filename2); @@ -2661,32 +2591,32 @@ static void testAddCertificateLink(void) store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); CloseHandle(file); /* Test adding a link to a file store. */ ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (ret) { ok(linked->hCertStore == store2, "unexpected store\n"); ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); - buf = HeapAlloc(GetProcessHeap(), 0, size); + buf = malloc(size); if (buf) { ret = CertSerializeCertificateStoreElement(linked, 0, buf, &size); - ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", + ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError()); /* The serialized linked certificate now contains the friendly * name property. */ ok(size == sizeof(serializedCertWithFriendlyName), - "Wrong size %d\n", size); + "Wrong size %ld\n", size); ok(!memcmp(serializedCertWithFriendlyName, buf, size), "Unexpected serialized cert\n"); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } CertFreeCertificateContext(linked); compareStore(store2, "file store -> file store", @@ -2709,7 +2639,7 @@ static void testAddCertificateLink(void) ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, &linked); ok(!ret && GetLastError() == E_INVALIDARG, - "expected E_INVALIDARG, got %08x\n", GetLastError()); + "expected E_INVALIDARG, got %08lx\n", GetLastError()); CertFreeCertificateContext(source); /* Test adding a link to a file store, where the linked certificate is @@ -2717,9 +2647,9 @@ static void testAddCertificateLink(void) */ ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &source); - ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", + ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError()); - if (!GetTempFileNameW(szDot, szPrefix, 0, filename1)) + if (!GetTempFileNameW(L".", L"cer", 0, filename1)) return; DeleteFileW(filename1); @@ -2730,12 +2660,12 @@ static void testAddCertificateLink(void) store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file); - ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); CloseHandle(file); ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (ret) { ok(linked->hCertStore == store2, "unexpected store\n"); @@ -2754,11 +2684,11 @@ static void testAddCertificateLink(void) * in a system store. */ store2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, - CERT_SYSTEM_STORE_CURRENT_USER, WineTestW); - ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); + CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest"); + ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError()); ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); - ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); + ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError()); if (ret) { ok(linked->hCertStore == store2, "unexpected store\n"); @@ -2852,10 +2782,10 @@ static void testEmptyStore(void) CertFreeCertificateContext(cert3); res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG); - ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%x)\n", res, GetLastError()); + ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError()); res = CertCloseStore(cert->hCertStore, 0); - ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%x)\n", res, GetLastError()); + ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError()); CertFreeCertificateContext(cert2); @@ -2938,7 +2868,7 @@ static void testCloseStore(void) /* There is still a reference from CTL */ res = CertCloseStore(store, CERT_CLOSE_STORE_CHECK_FLAG); - ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore returned: %x(%u)\n", res, GetLastError()); + ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore returned: %x(%lu)\n", res, GetLastError()); res = CertFreeCTLContext(ctl); ok(res, "CertFreeCTLContext failed\n"); @@ -2993,51 +2923,405 @@ static void test_I_UpdateStore(void) ret = pI_CertUpdatestore(NULL, store2, 0, 0); */ ret = pI_CertUpdatestore(store1, store2, 0, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); CertAddEncodedCertificateToStore(store2, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &cert); /* I_CertUpdateStore adds the contexts from store2 to store1 */ ret = pI_CertUpdatestore(store1, store2, 0, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); certs = countCertsInStore(store1); - ok(certs == 1, "Expected 1 cert, got %d\n", certs); + ok(certs == 1, "Expected 1 cert, got %ld\n", certs); /* Calling it a second time has no effect */ ret = pI_CertUpdatestore(store1, store2, 0, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); certs = countCertsInStore(store1); - ok(certs == 1, "Expected 1 cert, got %d\n", certs); + ok(certs == 1, "Expected 1 cert, got %ld\n", certs); /* The last parameters to I_CertUpdateStore appear to be ignored */ ret = pI_CertUpdatestore(store1, store2, 1, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); ret = pI_CertUpdatestore(store1, store2, 0, 1); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); CertAddEncodedCRLToStore(store2, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); /* I_CertUpdateStore also adds the CRLs from store2 to store1 */ ret = pI_CertUpdatestore(store1, store2, 0, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); certs = countCertsInStore(store1); - ok(certs == 1, "Expected 1 cert, got %d\n", certs); + ok(certs == 1, "Expected 1 cert, got %ld\n", certs); certs = countCRLsInStore(store1); - ok(certs == 1, "Expected 1 CRL, got %d\n", certs); + ok(certs == 1, "Expected 1 CRL, got %ld\n", certs); CertDeleteCertificateFromStore(cert); /* If a context is deleted from store2, I_CertUpdateStore deletes it * from store1 */ ret = pI_CertUpdatestore(store1, store2, 0, 0); - ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); + ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError()); certs = countCertsInStore(store1); - ok(certs == 0, "Expected 0 certs, got %d\n", certs); + ok(certs == 0, "Expected 0 certs, got %ld\n", certs); CertCloseStore(store1, 0); CertCloseStore(store2, 0); } +static const BYTE pfxdata[] = +{ + 0x30, 0x82, 0x0b, 0x1d, 0x02, 0x01, 0x03, 0x30, 0x82, 0x0a, 0xe3, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, + 0x0a, 0xd4, 0x04, 0x82, 0x0a, 0xd0, 0x30, 0x82, 0x0a, 0xcc, 0x30, 0x82, + 0x05, 0x07, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, + 0x06, 0xa0, 0x82, 0x04, 0xf8, 0x30, 0x82, 0x04, 0xf4, 0x02, 0x01, 0x00, + 0x30, 0x82, 0x04, 0xed, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, + 0x0d, 0x01, 0x0c, 0x01, 0x06, 0x30, 0x0e, 0x04, 0x08, 0xac, 0x3e, 0x35, + 0xa8, 0xed, 0x0d, 0x50, 0x07, 0x02, 0x02, 0x08, 0x00, 0x80, 0x82, 0x04, + 0xc0, 0x5a, 0x62, 0x55, 0x25, 0xf6, 0x2c, 0xf1, 0x78, 0x6c, 0x63, 0x96, + 0x8a, 0xea, 0x04, 0x64, 0xb3, 0x99, 0x3b, 0x80, 0x50, 0x05, 0x37, 0x55, + 0xa3, 0x5e, 0x9f, 0x35, 0xc3, 0x3c, 0xdc, 0xf6, 0xc4, 0xc1, 0x39, 0xa2, + 0xd7, 0x50, 0xad, 0xf9, 0x29, 0x3c, 0x51, 0xea, 0x15, 0x20, 0x25, 0xd3, + 0x4d, 0x69, 0xdf, 0x10, 0xd8, 0x9d, 0x60, 0x78, 0x8a, 0x70, 0x44, 0x7f, + 0x01, 0x4f, 0x4a, 0xfa, 0xab, 0xfd, 0x46, 0x48, 0x96, 0x2b, 0x69, 0xfc, + 0x11, 0xf8, 0x3f, 0xd3, 0x79, 0x09, 0x75, 0x81, 0x47, 0xdf, 0xce, 0xfe, + 0x07, 0x2f, 0x0a, 0xd8, 0xac, 0x87, 0x14, 0x1f, 0x7b, 0x95, 0x70, 0xee, + 0x7e, 0x52, 0x90, 0x11, 0xd6, 0x69, 0xf4, 0xd5, 0x38, 0x85, 0xc9, 0xc1, + 0x07, 0x01, 0xe8, 0xbb, 0xfb, 0xe2, 0x08, 0xa8, 0xfa, 0xbf, 0xf0, 0x92, + 0x63, 0x1d, 0xbb, 0x2b, 0x45, 0x6f, 0xce, 0x97, 0x01, 0xd7, 0x95, 0xf0, + 0x9c, 0x9a, 0x6b, 0x73, 0x01, 0xbf, 0xf9, 0x3d, 0xc8, 0x2b, 0x86, 0x7a, + 0xd5, 0x65, 0x84, 0xd7, 0xff, 0xb2, 0xf9, 0x20, 0x52, 0x35, 0xc5, 0x60, + 0x33, 0x70, 0x1d, 0x2f, 0x26, 0x09, 0x1c, 0x22, 0x17, 0xd8, 0x08, 0x4e, + 0x69, 0x20, 0xe2, 0x71, 0xe4, 0x07, 0xb1, 0x48, 0x5f, 0x20, 0x08, 0x7a, + 0xbf, 0x65, 0x53, 0x23, 0x07, 0xf9, 0x6c, 0xde, 0x3e, 0x29, 0xbf, 0x6b, + 0xef, 0xbb, 0x6a, 0x5f, 0x79, 0xa1, 0x72, 0xa1, 0x10, 0x24, 0x80, 0xb4, + 0x44, 0xb8, 0xc9, 0xfc, 0xa3, 0x36, 0x7e, 0x23, 0x37, 0x58, 0xc6, 0x1e, + 0xe8, 0x42, 0x4d, 0xb5, 0xf5, 0x58, 0x93, 0x21, 0x38, 0xa2, 0xc4, 0xa9, + 0x01, 0x96, 0xf9, 0x61, 0xac, 0x55, 0xb3, 0x3d, 0xe4, 0x54, 0x8b, 0x6c, + 0xc3, 0x83, 0xff, 0x50, 0x87, 0x94, 0xe8, 0x35, 0x3c, 0x26, 0x0d, 0x20, + 0x8a, 0x25, 0x0e, 0xb6, 0x67, 0x78, 0x29, 0xc7, 0xbf, 0x76, 0x8e, 0x62, + 0x62, 0xc4, 0x50, 0xd6, 0xc5, 0x3c, 0xb4, 0x7a, 0x35, 0xbe, 0x53, 0x52, + 0xc4, 0xe4, 0x10, 0xb3, 0xe0, 0x73, 0xb0, 0xd1, 0xc1, 0x5a, 0x4f, 0x4e, + 0x64, 0x0d, 0x92, 0x51, 0x2d, 0x4d, 0xec, 0xb0, 0xc6, 0x40, 0x1b, 0x03, + 0x89, 0x7f, 0xc2, 0x2c, 0xe3, 0x2c, 0xbd, 0x8c, 0x9c, 0xd9, 0xe0, 0x08, + 0x59, 0xd3, 0xaf, 0x48, 0x56, 0x89, 0x60, 0x85, 0x76, 0xe0, 0xd8, 0x7c, + 0xcf, 0x02, 0x8f, 0xfd, 0xb2, 0x8f, 0x2b, 0x61, 0xcf, 0x28, 0x56, 0x8b, + 0x6b, 0x03, 0x2b, 0x2f, 0x83, 0x31, 0xa0, 0x1c, 0xd1, 0x6c, 0x87, 0x49, + 0xc4, 0x77, 0x55, 0x1f, 0x61, 0x45, 0x58, 0x88, 0x9f, 0x01, 0xc3, 0x63, + 0x62, 0x30, 0x35, 0xdf, 0x61, 0x74, 0x55, 0x63, 0x3f, 0xae, 0x41, 0xc1, + 0xb8, 0xf0, 0x9f, 0xab, 0x25, 0xad, 0x41, 0x5c, 0x1f, 0x00, 0x0d, 0xef, + 0xf0, 0xcf, 0xaf, 0x41, 0x23, 0xca, 0x8c, 0x38, 0xea, 0x5a, 0xe4, 0x8b, + 0xb4, 0x89, 0xd0, 0x76, 0x7f, 0x2b, 0x77, 0x8f, 0xe4, 0x44, 0xd5, 0x37, + 0xac, 0xc2, 0x09, 0x7e, 0x7e, 0x7e, 0x02, 0x5c, 0x27, 0x01, 0xcb, 0x4d, + 0xea, 0xb3, 0x97, 0x36, 0x35, 0xd2, 0x05, 0x3c, 0x4e, 0xb8, 0x04, 0x5c, + 0xb8, 0x95, 0x3f, 0xc6, 0xbf, 0xd4, 0x20, 0x01, 0xfb, 0xed, 0x37, 0x5a, + 0xad, 0x4c, 0x61, 0x93, 0xfe, 0x95, 0x7c, 0x34, 0x11, 0x15, 0x9d, 0x00, + 0x0b, 0x99, 0x69, 0xcb, 0x7e, 0xb9, 0x53, 0x46, 0x57, 0x39, 0x3f, 0x59, + 0x4b, 0x30, 0x8d, 0xfb, 0x84, 0x66, 0x2d, 0x06, 0xc9, 0x88, 0xa6, 0x18, + 0xd7, 0x36, 0xc6, 0xf6, 0xf7, 0x47, 0x85, 0x38, 0xc8, 0x3d, 0x37, 0xea, + 0x57, 0x4c, 0xb0, 0x7c, 0x95, 0x29, 0x84, 0xab, 0xbb, 0x19, 0x86, 0xc2, + 0xc5, 0x99, 0x01, 0x38, 0x6b, 0xf1, 0xd3, 0x1d, 0xa8, 0x02, 0xf9, 0x6f, + 0xaa, 0xf1, 0x57, 0xd0, 0x88, 0x68, 0x62, 0x5f, 0x9f, 0x7a, 0x63, 0xba, + 0x3a, 0xc9, 0x95, 0x11, 0x3c, 0xf9, 0xa1, 0xc1, 0x35, 0xfe, 0xd5, 0x12, + 0x49, 0x88, 0x0d, 0x5c, 0xe2, 0xd1, 0x15, 0x18, 0xfb, 0xd5, 0x7f, 0x19, + 0x3f, 0xaf, 0xa0, 0xcb, 0x31, 0x20, 0x9e, 0x03, 0x93, 0xa4, 0x66, 0xbd, + 0x83, 0xe8, 0x60, 0x34, 0x55, 0x0d, 0x97, 0x10, 0x23, 0x24, 0x7a, 0x45, + 0x36, 0xb4, 0xc4, 0xee, 0x60, 0x6f, 0xd8, 0x46, 0xc5, 0xac, 0x2b, 0xa9, + 0x18, 0x74, 0x83, 0x1e, 0xdf, 0x7c, 0x1a, 0x5a, 0xe8, 0x5f, 0x8b, 0x4f, + 0x9f, 0x40, 0x3e, 0x5e, 0xfb, 0xd3, 0x68, 0xac, 0x34, 0x62, 0x30, 0x23, + 0xb6, 0xbc, 0xdf, 0xbc, 0xc7, 0x25, 0xd2, 0x1b, 0x57, 0x33, 0xfb, 0x78, + 0x22, 0x21, 0x1e, 0x3a, 0xf6, 0x44, 0x18, 0x7e, 0x12, 0x36, 0x47, 0x58, + 0xd0, 0x59, 0x26, 0x98, 0x98, 0x95, 0xf4, 0xd1, 0xaa, 0x45, 0xaa, 0xe7, + 0xd1, 0xe6, 0x2d, 0x78, 0xf0, 0x8b, 0x1c, 0xfd, 0xf8, 0x50, 0x60, 0xa2, + 0x1e, 0x7f, 0xe3, 0x31, 0x77, 0x31, 0x58, 0x99, 0x0f, 0xda, 0x0e, 0xa3, + 0xc6, 0x7a, 0x30, 0x45, 0x55, 0x11, 0x91, 0x77, 0x41, 0x79, 0xd3, 0x56, + 0xb2, 0x07, 0x00, 0x61, 0xab, 0xec, 0x27, 0xc7, 0x9f, 0xfa, 0x89, 0x08, + 0xc2, 0x87, 0xcf, 0xe9, 0xdc, 0x9e, 0x29, 0x22, 0xfb, 0x23, 0x7f, 0x9d, + 0x89, 0xd5, 0x6e, 0x75, 0x20, 0xd8, 0x00, 0x5b, 0xc4, 0x94, 0xbb, 0xc5, + 0xb2, 0xba, 0x77, 0x2b, 0xf6, 0x3c, 0x88, 0xb0, 0x4c, 0x38, 0x46, 0x55, + 0xee, 0x8b, 0x03, 0x15, 0xbc, 0x0a, 0x1d, 0x47, 0x87, 0x44, 0xaf, 0xb1, + 0x2a, 0xa7, 0x4d, 0x08, 0xdf, 0x3b, 0x2d, 0x70, 0xa1, 0x67, 0x31, 0x76, + 0x6e, 0x6f, 0x40, 0x3b, 0x3b, 0xe8, 0xf9, 0xdf, 0x90, 0xa4, 0xce, 0x7f, + 0xb8, 0x2d, 0x69, 0xcb, 0x1c, 0x1e, 0x94, 0xcd, 0xb1, 0xd8, 0x43, 0x22, + 0xb8, 0x4f, 0x98, 0x92, 0x74, 0xb3, 0xde, 0xeb, 0x7a, 0xcb, 0xfa, 0xd0, + 0x36, 0xe4, 0x5d, 0xfa, 0xd3, 0xce, 0xf9, 0xba, 0x3e, 0x0f, 0x6c, 0xc3, + 0x5b, 0xb3, 0x81, 0x84, 0x6e, 0x5d, 0xc1, 0x21, 0x89, 0xec, 0x67, 0x9a, + 0xfd, 0x55, 0x20, 0xb0, 0x71, 0x53, 0xae, 0xf8, 0xa4, 0x8d, 0xd5, 0xe5, + 0x2d, 0x3a, 0xce, 0x89, 0x55, 0x8c, 0x4f, 0x3b, 0x37, 0x95, 0x4e, 0x15, + 0xbe, 0xe7, 0xd1, 0x7a, 0x36, 0x82, 0x45, 0x69, 0x7c, 0x27, 0x4f, 0xb9, + 0x4b, 0x7d, 0xcd, 0x59, 0xc8, 0xf4, 0x8b, 0x0f, 0x4f, 0x75, 0x23, 0xd3, + 0xd0, 0xc7, 0x10, 0x79, 0xc0, 0xf1, 0xac, 0x14, 0xf7, 0x0d, 0xc8, 0x5e, + 0xfc, 0xff, 0x1a, 0x2b, 0x10, 0x88, 0x7e, 0x7e, 0x2f, 0xfa, 0x7b, 0x9f, + 0x47, 0x23, 0x34, 0xfc, 0xf5, 0xde, 0xd9, 0xa3, 0x05, 0x99, 0x2a, 0x96, + 0x83, 0x3d, 0xa4, 0x7f, 0x6a, 0x66, 0x9b, 0xe7, 0xf1, 0x00, 0x4e, 0x9a, + 0xfc, 0x68, 0xd2, 0x74, 0x17, 0xba, 0xc9, 0xc8, 0x20, 0x39, 0xa1, 0xa8, + 0x85, 0xc6, 0x10, 0x2b, 0xab, 0x97, 0x34, 0x2d, 0x49, 0x68, 0x57, 0xb0, + 0x43, 0xee, 0x25, 0xbb, 0x35, 0x1b, 0x03, 0x99, 0xa3, 0x21, 0x68, 0x66, + 0x86, 0x3f, 0xc6, 0xfc, 0x49, 0xf0, 0xba, 0x5f, 0x00, 0xc6, 0xe3, 0x1c, + 0xb2, 0x9f, 0x16, 0x7f, 0xc7, 0x40, 0x4a, 0x9a, 0x39, 0xc1, 0x95, 0x69, + 0xa2, 0x87, 0xba, 0x58, 0xc6, 0xf2, 0xd6, 0x66, 0xa6, 0x4c, 0x6d, 0x29, + 0x9c, 0xa8, 0x6e, 0xa9, 0xd2, 0xe4, 0x54, 0x17, 0x89, 0xe2, 0x43, 0xf0, + 0xe1, 0x8b, 0x57, 0x84, 0x6c, 0x87, 0x63, 0x17, 0xbb, 0xf6, 0x33, 0x1b, + 0xe4, 0x34, 0x6a, 0x80, 0x70, 0x7b, 0x1b, 0xfd, 0xf8, 0x79, 0x28, 0xc8, + 0x3c, 0x8e, 0xa4, 0xd5, 0xb8, 0x96, 0x54, 0xd4, 0xec, 0x72, 0xe5, 0x40, + 0x8f, 0x56, 0xde, 0x82, 0x15, 0x72, 0x4d, 0xd8, 0x0c, 0x07, 0xea, 0xe6, + 0x44, 0xcd, 0x94, 0x73, 0x5c, 0x04, 0xe8, 0x8e, 0xb7, 0xc7, 0xc9, 0x29, + 0xdc, 0x04, 0xef, 0x7c, 0x31, 0x9b, 0x50, 0xbc, 0xea, 0x71, 0x1f, 0x28, + 0x22, 0xb6, 0x04, 0x53, 0x2e, 0x71, 0xc4, 0xf6, 0xbb, 0x88, 0x51, 0xee, + 0x3e, 0x76, 0x65, 0xb4, 0x4b, 0x1b, 0xa3, 0xec, 0x7b, 0xa7, 0x9d, 0x31, + 0x5d, 0xb8, 0x9f, 0xab, 0x6b, 0x54, 0x7d, 0xbd, 0xc1, 0x2c, 0x55, 0xb0, + 0x23, 0x8c, 0x06, 0x60, 0x01, 0x4f, 0x60, 0x85, 0x56, 0x7f, 0xfb, 0x99, + 0x0c, 0xdc, 0x8c, 0x09, 0x37, 0x46, 0x5b, 0x97, 0x5d, 0xe8, 0x31, 0x00, + 0x1b, 0x30, 0x9b, 0x02, 0x92, 0x29, 0xb5, 0x20, 0xce, 0x4b, 0x90, 0xfb, + 0x91, 0x07, 0x5a, 0xd3, 0xf5, 0xa0, 0xe6, 0x8f, 0xf8, 0x73, 0xc5, 0x4b, + 0xbb, 0xad, 0x2a, 0xeb, 0xa8, 0xb7, 0x68, 0x34, 0x36, 0x47, 0xd5, 0x4b, + 0x61, 0x89, 0x53, 0xe6, 0xb6, 0xb1, 0x07, 0xe4, 0x08, 0x2e, 0xed, 0x50, + 0xd4, 0x1e, 0xed, 0x7f, 0xbf, 0x35, 0x68, 0x04, 0x45, 0x72, 0x86, 0x71, + 0x15, 0x55, 0xdf, 0xe6, 0x30, 0xc0, 0x8b, 0x8a, 0xb0, 0x6c, 0xd0, 0x35, + 0x57, 0x8f, 0x04, 0x37, 0xbc, 0xe1, 0xb8, 0xbf, 0x27, 0x37, 0x3d, 0xd0, + 0xc8, 0x46, 0x67, 0x42, 0x51, 0x30, 0x82, 0x05, 0xbd, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x05, 0xae, + 0x04, 0x82, 0x05, 0xaa, 0x30, 0x82, 0x05, 0xa6, 0x30, 0x82, 0x05, 0xa2, + 0x06, 0x0b, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01, + 0x02, 0xa0, 0x82, 0x04, 0xee, 0x30, 0x82, 0x04, 0xea, 0x30, 0x1c, 0x06, + 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30, + 0x0e, 0x04, 0x08, 0x9f, 0xa4, 0x72, 0x2b, 0x6b, 0x0e, 0xcb, 0x9f, 0x02, + 0x02, 0x08, 0x00, 0x04, 0x82, 0x04, 0xc8, 0xe5, 0x35, 0xb9, 0x72, 0x28, + 0x20, 0x28, 0xad, 0xe3, 0x01, 0xd7, 0x0b, 0xe0, 0x4e, 0x36, 0xc3, 0x73, + 0x06, 0xd5, 0xf6, 0x75, 0x1a, 0x78, 0xb2, 0xd8, 0xf6, 0x5a, 0x85, 0x8e, + 0x50, 0xa3, 0x05, 0x49, 0x02, 0x2d, 0xf8, 0xa3, 0x2f, 0xe6, 0x02, 0x7a, + 0xd5, 0x0b, 0x1d, 0xf1, 0xd1, 0xe4, 0x16, 0xaa, 0x70, 0x2e, 0x34, 0xdb, + 0x56, 0xd9, 0x33, 0x94, 0x11, 0xaa, 0x60, 0xd4, 0xfa, 0x5b, 0xd1, 0xb3, + 0x2e, 0x86, 0x6a, 0x5a, 0x69, 0xdf, 0x11, 0x91, 0xb0, 0xca, 0x82, 0xff, + 0x63, 0xad, 0x6a, 0x0b, 0x90, 0xa6, 0xc7, 0x9b, 0xef, 0x9a, 0xf8, 0x96, + 0xec, 0xe4, 0xc4, 0xdf, 0x55, 0x4c, 0x12, 0x07, 0xab, 0x7c, 0x5c, 0x68, + 0x47, 0xf2, 0x92, 0xfb, 0x94, 0xab, 0xc3, 0x64, 0xd3, 0xfe, 0xb2, 0x16, + 0xb4, 0x78, 0x80, 0x52, 0xe9, 0x32, 0x39, 0x3b, 0x8d, 0x12, 0x91, 0x36, + 0xfd, 0xa1, 0x97, 0xc2, 0x0a, 0x4a, 0xf1, 0xb3, 0x8a, 0xe4, 0x01, 0xed, + 0x0a, 0xda, 0x2e, 0xa0, 0x38, 0xa9, 0x47, 0x3d, 0x3a, 0x64, 0x87, 0x06, + 0xc3, 0x83, 0x60, 0xaf, 0x84, 0xdb, 0x87, 0xff, 0x70, 0x61, 0x43, 0x7d, + 0x2d, 0x61, 0x9a, 0xf7, 0x0d, 0xca, 0x0c, 0x0f, 0xbe, 0x43, 0x5b, 0x99, + 0xe1, 0x90, 0x64, 0x1f, 0xa7, 0x1b, 0xa6, 0xa6, 0x5c, 0x13, 0x70, 0xa3, + 0xdb, 0xd7, 0xf0, 0xe8, 0x7a, 0xb0, 0xd1, 0x9b, 0x52, 0xa6, 0x4f, 0xd6, + 0xff, 0x54, 0x4d, 0xa6, 0x15, 0x05, 0x5c, 0xe9, 0x04, 0x6a, 0xc3, 0x49, + 0x12, 0x2f, 0x24, 0x03, 0xc3, 0x80, 0x06, 0xa6, 0x07, 0x8b, 0x96, 0xe7, + 0x39, 0x31, 0x6d, 0xd3, 0x1b, 0xa5, 0x45, 0x58, 0x04, 0xe7, 0x87, 0xdf, + 0x26, 0xfb, 0x1b, 0x9f, 0x92, 0x93, 0x32, 0x12, 0x9a, 0xc9, 0xe6, 0xcb, + 0x88, 0x14, 0x9f, 0x23, 0x0b, 0x52, 0xa2, 0xb8, 0x32, 0x6c, 0xa9, 0x33, + 0xa1, 0x17, 0xe8, 0x4a, 0xd4, 0x5c, 0x7d, 0xb3, 0xa3, 0x64, 0x86, 0x03, + 0x7c, 0x7c, 0x3f, 0x99, 0xdc, 0x21, 0x9f, 0x93, 0xc6, 0xb9, 0x1d, 0xe0, + 0x21, 0x79, 0x78, 0x35, 0xdc, 0x1e, 0x27, 0x3c, 0x73, 0x7f, 0x0f, 0xd6, + 0x4f, 0xde, 0xe9, 0xb4, 0xb7, 0xe3, 0xf5, 0x72, 0xce, 0x42, 0xf3, 0x91, + 0x5b, 0x84, 0xba, 0xbb, 0xae, 0xf0, 0x87, 0x0f, 0x50, 0xa4, 0x5e, 0x80, + 0x23, 0x57, 0x2b, 0xa0, 0xa3, 0xc3, 0x8a, 0x2f, 0xa8, 0x7a, 0x1a, 0x65, + 0x8f, 0x62, 0xf8, 0x3e, 0xe2, 0xcd, 0xbc, 0x63, 0x56, 0x8e, 0x77, 0xf3, + 0xf9, 0x69, 0x10, 0x57, 0xa8, 0xaf, 0x67, 0x2a, 0x9f, 0x7f, 0x7e, 0xeb, + 0x1d, 0x99, 0xa6, 0x67, 0xcd, 0x9e, 0x42, 0x2e, 0x5e, 0x4e, 0x61, 0x24, + 0xfa, 0xca, 0x2a, 0xeb, 0x62, 0x1f, 0xa3, 0x14, 0x0a, 0x06, 0x4b, 0x77, + 0x78, 0x77, 0x9b, 0xf1, 0x03, 0xcc, 0xb5, 0xfe, 0xfb, 0x7a, 0x77, 0xa6, + 0x82, 0x9f, 0xe5, 0xde, 0x9d, 0x0d, 0x4d, 0x37, 0xc6, 0x12, 0x73, 0x6d, + 0xea, 0xbb, 0x48, 0xf0, 0xd2, 0x81, 0xcc, 0x1a, 0x47, 0xfa, 0xa4, 0xd2, + 0xb2, 0x27, 0xa0, 0xfc, 0x30, 0x04, 0xdb, 0x05, 0xd3, 0x0b, 0xbc, 0x4d, + 0x7a, 0x99, 0xef, 0x7f, 0x26, 0x01, 0xd4, 0x07, 0x0b, 0x1e, 0x99, 0x06, + 0x3c, 0xde, 0x3d, 0x1c, 0x21, 0x82, 0x68, 0x46, 0x35, 0x38, 0x61, 0xea, + 0xd4, 0xc2, 0x65, 0x09, 0x39, 0x87, 0xb4, 0xd3, 0x5d, 0x3c, 0xa3, 0x79, + 0xe4, 0x01, 0x4e, 0xbf, 0x18, 0xba, 0x57, 0x3f, 0xdd, 0xea, 0x0a, 0x6b, + 0x99, 0xfb, 0x93, 0xfa, 0xab, 0xee, 0x08, 0xdf, 0x38, 0x23, 0xae, 0x8d, + 0xa8, 0x03, 0x13, 0xfe, 0x83, 0x88, 0xb0, 0xc2, 0xf9, 0x90, 0xa5, 0x1c, + 0x01, 0x6f, 0x71, 0x91, 0x42, 0x35, 0x81, 0x74, 0x71, 0x6c, 0xba, 0x86, + 0x48, 0xfe, 0x96, 0xd2, 0x88, 0x12, 0x36, 0x4e, 0xa6, 0x2f, 0xd1, 0xdb, + 0xfa, 0xbf, 0xdb, 0x84, 0x01, 0xfc, 0x7d, 0x7a, 0xac, 0x20, 0xae, 0xf5, + 0x95, 0xc9, 0xdc, 0x10, 0x5f, 0x4c, 0xae, 0x85, 0x01, 0x8b, 0xfe, 0x77, + 0x13, 0x01, 0xae, 0x39, 0x59, 0x7e, 0xbc, 0xfd, 0xc9, 0x42, 0xe4, 0x13, + 0x07, 0x3f, 0xa9, 0x74, 0xd9, 0xd5, 0xfc, 0xb9, 0x78, 0xbe, 0x97, 0xf5, + 0xe7, 0x36, 0x7f, 0xfa, 0x23, 0x30, 0xeb, 0xab, 0x92, 0xd3, 0xdc, 0x3f, + 0x7f, 0xc0, 0x77, 0x93, 0xf9, 0x88, 0xe3, 0x4e, 0x13, 0x53, 0x6d, 0x71, + 0x87, 0xe9, 0x24, 0x2b, 0xae, 0x26, 0xbf, 0x62, 0x51, 0x04, 0x42, 0xe1, + 0x13, 0x9d, 0xd8, 0x9f, 0x59, 0x87, 0x3f, 0xfc, 0x94, 0xff, 0xcf, 0x88, + 0x88, 0xe6, 0xeb, 0x6e, 0xc1, 0x96, 0x04, 0x27, 0xc8, 0xda, 0xfa, 0xe8, + 0x2e, 0xbb, 0x2c, 0x6e, 0xf4, 0xb4, 0x00, 0x7d, 0x8d, 0x3b, 0xef, 0x8b, + 0x18, 0xa9, 0x5f, 0x32, 0xa9, 0xf2, 0x3a, 0x7e, 0x65, 0x2d, 0x6e, 0x8d, + 0x75, 0x77, 0xf6, 0xa6, 0xd8, 0xf9, 0x6b, 0x51, 0xe6, 0x66, 0x52, 0x59, + 0x39, 0x97, 0x22, 0xda, 0xb2, 0xd6, 0x82, 0x5a, 0x6e, 0x61, 0x60, 0x16, + 0x48, 0x7b, 0xf1, 0xc3, 0x4d, 0x7f, 0x50, 0xfa, 0x4d, 0x58, 0x27, 0x30, + 0xc8, 0x96, 0xe0, 0x41, 0x4f, 0x6b, 0xeb, 0x88, 0xa2, 0x7a, 0xef, 0x8a, + 0x88, 0xc8, 0x50, 0x4b, 0x55, 0x66, 0xee, 0xbf, 0xc4, 0x01, 0x82, 0x4c, + 0xec, 0xde, 0x37, 0x64, 0xd6, 0x1e, 0xcf, 0x3e, 0x2e, 0xfe, 0x84, 0x68, + 0xbf, 0xa3, 0x68, 0x77, 0xa9, 0x03, 0xe4, 0xf8, 0xd7, 0xb2, 0x6e, 0xa3, + 0xc4, 0xc3, 0x36, 0x53, 0xf3, 0xdd, 0x7e, 0x4c, 0xf0, 0xe9, 0xb2, 0x44, + 0xe6, 0x60, 0x3d, 0x00, 0x9a, 0x08, 0xc3, 0x21, 0x17, 0x49, 0xda, 0x49, + 0xfb, 0x4c, 0x8b, 0xe9, 0x10, 0x66, 0xfe, 0xb7, 0xe0, 0xf9, 0xdd, 0xbf, + 0x41, 0xfe, 0x04, 0x9b, 0x7f, 0xe8, 0xd6, 0x2e, 0x4d, 0x0f, 0x7b, 0x10, + 0x73, 0x4c, 0xa1, 0x3e, 0x43, 0xb7, 0xcf, 0x94, 0x97, 0x7e, 0x24, 0xbb, + 0x87, 0xbf, 0x22, 0xb8, 0x3e, 0xeb, 0x9a, 0x3f, 0xe3, 0x86, 0xee, 0x21, + 0xbc, 0xf5, 0x44, 0xeb, 0x60, 0x2e, 0xe7, 0x8f, 0x89, 0xa4, 0x91, 0x61, + 0x28, 0x90, 0x85, 0x68, 0xe0, 0xa9, 0x62, 0x93, 0x86, 0x5a, 0x15, 0xbe, + 0xb2, 0x76, 0x83, 0xf2, 0x0f, 0x00, 0xc7, 0xb6, 0x57, 0xe9, 0x1f, 0x92, + 0x49, 0xfe, 0x50, 0x85, 0xbf, 0x39, 0x3d, 0xe4, 0x8b, 0x72, 0x2d, 0x49, + 0xbe, 0x05, 0x0a, 0x34, 0x56, 0x80, 0xc6, 0x1f, 0x46, 0x59, 0xc9, 0xfe, + 0x40, 0xfb, 0x78, 0x6d, 0x7a, 0xe5, 0x30, 0xe9, 0x81, 0x55, 0x75, 0x05, + 0x63, 0xd2, 0x22, 0xee, 0x2e, 0x6e, 0xb9, 0x18, 0xe5, 0x8a, 0x5a, 0x66, + 0xbd, 0x74, 0x30, 0xe3, 0x8b, 0x76, 0x22, 0x18, 0x1e, 0xef, 0x69, 0xe8, + 0x9d, 0x07, 0xa7, 0x9a, 0x87, 0x6c, 0x04, 0x4b, 0x74, 0x2b, 0xbe, 0x37, + 0x2f, 0x29, 0x9b, 0x60, 0x9d, 0x8b, 0x57, 0x55, 0x34, 0xca, 0x41, 0x25, + 0xae, 0x56, 0x92, 0x34, 0x1b, 0x9e, 0xbd, 0xfe, 0x74, 0xbd, 0x4e, 0x29, + 0xf0, 0x5e, 0x27, 0x94, 0xb0, 0x9e, 0x23, 0x9f, 0x4a, 0x0f, 0xa1, 0xdf, + 0xe7, 0xc4, 0xdb, 0xbe, 0x0f, 0x1a, 0x0b, 0x6c, 0xb0, 0xe1, 0x06, 0x7c, + 0x5a, 0x5b, 0x81, 0x1c, 0xb6, 0x12, 0xec, 0x6f, 0x3b, 0xbb, 0x84, 0x36, + 0xd5, 0x28, 0x16, 0xea, 0x51, 0xa8, 0x99, 0x24, 0x8f, 0xe7, 0xf8, 0xe9, + 0xce, 0xa1, 0x65, 0x96, 0x6f, 0x4e, 0x2f, 0xb7, 0x6f, 0x65, 0x39, 0xad, + 0xfd, 0x2e, 0xa0, 0x37, 0x32, 0x2f, 0xf3, 0x95, 0xa1, 0x3a, 0xa1, 0x9d, + 0x2c, 0x9e, 0xa1, 0x4b, 0x7e, 0xc9, 0x7e, 0x86, 0xaa, 0x16, 0x00, 0x82, + 0x1d, 0x36, 0xbf, 0x98, 0x0a, 0x82, 0x5b, 0xcc, 0xc4, 0x6a, 0xad, 0xa0, + 0x1f, 0x47, 0x98, 0xde, 0x8d, 0x68, 0x38, 0x3f, 0x33, 0xe2, 0x08, 0x3b, + 0x2a, 0x65, 0xd9, 0x2f, 0x53, 0x68, 0xb8, 0x78, 0xd0, 0x1d, 0xbb, 0x2a, + 0x73, 0x19, 0xba, 0x58, 0xea, 0xf1, 0x0a, 0xaa, 0xa6, 0xbe, 0x27, 0xd6, + 0x00, 0x6b, 0x4e, 0x43, 0x8e, 0x5b, 0x19, 0xc1, 0x37, 0x0f, 0xfb, 0x81, + 0x72, 0x10, 0xb6, 0x20, 0x32, 0xcd, 0xa2, 0x7c, 0x90, 0xd4, 0xf5, 0xcf, + 0x1c, 0xcb, 0x14, 0x24, 0x7a, 0x4d, 0xf5, 0xd5, 0xd9, 0xce, 0x6a, 0x64, + 0xc9, 0xd3, 0xa7, 0x36, 0x6f, 0x1d, 0xf1, 0xe9, 0x71, 0x6c, 0x3d, 0x02, + 0xa4, 0x62, 0xb1, 0x82, 0x5c, 0x13, 0x4b, 0x6b, 0x68, 0xe2, 0x31, 0xef, + 0xe4, 0x46, 0xfd, 0xe5, 0xa8, 0x29, 0xe9, 0x1e, 0xad, 0xff, 0x33, 0xdb, + 0x0b, 0xc0, 0x92, 0xb1, 0xef, 0xeb, 0xb3, 0x6f, 0x96, 0x7b, 0xdf, 0xcd, + 0x07, 0x19, 0x86, 0x60, 0x98, 0xcf, 0x95, 0xfe, 0x98, 0xdd, 0x29, 0xa6, + 0x35, 0x7b, 0x46, 0x13, 0x03, 0xa8, 0xd9, 0x7c, 0xb3, 0xdf, 0x9f, 0x14, + 0xb7, 0x34, 0x5a, 0xc4, 0x12, 0x81, 0xc5, 0x98, 0x25, 0x8d, 0x3e, 0xe3, + 0xd8, 0x2d, 0xe4, 0x54, 0xab, 0xb0, 0x13, 0xfd, 0xd1, 0x3f, 0x3b, 0xbf, + 0xa9, 0x45, 0x28, 0x8a, 0x2f, 0x9c, 0x1e, 0x2d, 0xe5, 0xab, 0x13, 0x95, + 0x97, 0xc3, 0x34, 0x37, 0x8d, 0x93, 0x66, 0x31, 0x81, 0xa0, 0x30, 0x23, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x15, 0x31, + 0x16, 0x04, 0x14, 0xa5, 0x23, 0x9b, 0x7e, 0xe6, 0x45, 0x71, 0xbf, 0x48, + 0xc6, 0x27, 0x3c, 0x96, 0x87, 0x63, 0xbd, 0x1f, 0xde, 0x72, 0x12, 0x30, + 0x79, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01, + 0x31, 0x6c, 0x1e, 0x6a, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, + 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20, + 0x00, 0x45, 0x00, 0x6e, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x63, + 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41, + 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, + 0x00, 0x45, 0x00, 0x53, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79, + 0x00, 0x70, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, + 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50, + 0x00, 0x72, 0x00, 0x6f, 0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, + 0x00, 0x72, 0x30, 0x31, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, + 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x93, 0xa8, 0xb2, 0x7e, 0xb7, + 0xab, 0xf1, 0x1c, 0x3c, 0x36, 0x58, 0xdc, 0x67, 0x6d, 0x42, 0xa6, 0xfc, + 0x53, 0x01, 0xe6, 0x04, 0x08, 0x77, 0x57, 0x22, 0xa1, 0x7d, 0xb9, 0xa2, + 0x69, 0x02, 0x02, 0x08, 0x00 +}; + +static void test_PFXImportCertStore(void) +{ + HCERTSTORE store; + CRYPT_DATA_BLOB pfx; + const CERT_CONTEXT *cert; + CERT_KEY_CONTEXT key; + char buf[512]; + CRYPT_KEY_PROV_INFO *keyprov = (CRYPT_KEY_PROV_INFO *)buf; + CERT_INFO *info; + DWORD count, size; + BOOL ret; + + SetLastError( 0xdeadbeef ); + store = PFXImportCertStore( NULL, NULL, 0 ); + ok( store == NULL, "got %p\n", store ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError() ); + + pfx.pbData = (BYTE *)pfxdata; + pfx.cbData = sizeof(pfxdata); + store = PFXImportCertStore( &pfx, NULL, CRYPT_EXPORTABLE|CRYPT_USER_KEYSET|PKCS12_NO_PERSIST_KEY ); + ok( store != NULL, "got %lu\n", GetLastError() ); + count = countCertsInStore( store ); + ok( count == 1, "got %lu\n", count ); + + cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL ); + ok( cert != NULL, "got %lu\n", GetLastError() ); + ok( cert->dwCertEncodingType == X509_ASN_ENCODING, "got %lu\n", cert->dwCertEncodingType ); + ok( cert->pbCertEncoded != NULL, "pbCertEncoded not set\n" ); + ok( cert->cbCertEncoded == 1123, "got %lu\n", cert->cbCertEncoded ); + ok( cert->pCertInfo != NULL, "pCertInfo not set\n" ); + ok( cert->hCertStore == store, "got %p\n", cert->hCertStore ); + + info = cert->pCertInfo; + ok( info->dwVersion == CERT_V1, "got %lu\n", info->dwVersion ); + ok( !strcmp(info->SignatureAlgorithm.pszObjId, szOID_RSA_SHA256RSA), + "got \"%s\"\n", info->SignatureAlgorithm.pszObjId ); + + size = sizeof(key); + ret = CertGetCertificateContextProperty( cert, CERT_KEY_CONTEXT_PROP_ID, &key, &size ); + ok( ret, "got %08lx\n", GetLastError() ); + ok( key.cbSize == sizeof(key), "got %lu\n", key.cbSize ); + ok( key.hCryptProv, "hCryptProv not set\n" ); + ok( key.dwKeySpec == AT_KEYEXCHANGE, "got %lu\n", key.dwKeySpec ); + + size = sizeof(buf); + SetLastError( 0xdeadbeef ); + ret = CertGetCertificateContextProperty( cert, CERT_KEY_PROV_INFO_PROP_ID, keyprov, &size ); + ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() ); + CertFreeCertificateContext( cert ); + CertCloseStore( store, 0 ); + + /* without PKCS12_NO_PERSIST_KEY */ + store = PFXImportCertStore( &pfx, NULL, CRYPT_EXPORTABLE|CRYPT_USER_KEYSET ); + ok( store != NULL, "got %lu\n", GetLastError() ); + + cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL ); + ok( cert != NULL, "got %08lx\n", GetLastError() ); + + size = sizeof(key); + ret = CertGetCertificateContextProperty( cert, CERT_KEY_CONTEXT_PROP_ID, &key, &size ); + ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() ); + + size = sizeof(buf); + ret = CertGetCertificateContextProperty( cert, CERT_KEY_PROV_INFO_PROP_ID, buf, &size ); + ok(ret, "got %lu\n", GetLastError()); + CertFreeCertificateContext( cert ); + CertCloseStore( store, 0 ); + + /* CRYPT_MACHINE_KEYSET */ + store = PFXImportCertStore( &pfx, NULL, CRYPT_MACHINE_KEYSET ); + ok( store != NULL, "got %lu\n", GetLastError() ); + + cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL ); + ok( cert != NULL, "got %08lx\n", GetLastError() ); + + CertFreeCertificateContext( cert ); + CertCloseStore( store, 0 ); +} + +static void test_CryptQueryObject(void) +{ + CRYPT_DATA_BLOB pfx; + DWORD encoding_type, content_type, format_type; + HCERTSTORE store; + HCRYPTMSG msg; + const void *ctx; + BOOL ret; + + SetLastError( 0xdeadbeef ); + ret = CryptQueryObject( CERT_QUERY_OBJECT_BLOB, NULL, CERT_QUERY_CONTENT_FLAG_ALL, + CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL ); + ok( !ret, "success\n" ); + ok( GetLastError() == E_INVALIDARG, "got %lu\n", GetLastError() ); + + pfx.pbData = (BYTE *)pfxdata; + pfx.cbData = sizeof(pfxdata); + encoding_type = content_type = format_type = 0xdeadbeef; + store = (HCERTSTORE *)0xdeadbeef; + msg = (HCRYPTMSG *)0xdeadbeef; + ctx = (void *)0xdeadbeef; + ret = CryptQueryObject( CERT_QUERY_OBJECT_BLOB, &pfx, CERT_QUERY_CONTENT_FLAG_ALL, + CERT_QUERY_FORMAT_FLAG_BINARY, 0, &encoding_type, &content_type, &format_type, + &store, &msg, &ctx ); + ok( ret, "got %lu\n", GetLastError() ); + ok( encoding_type == X509_ASN_ENCODING, "got %08lx\n", encoding_type ); + ok( content_type == CERT_QUERY_CONTENT_PFX, "got %08lx\n", content_type ); + ok( format_type == CERT_QUERY_FORMAT_BINARY, "got %08lx\n", format_type ); + ok( store == NULL, "got %p\n", store ); + ok( msg == NULL, "got %p\n", msg ); + ok( ctx == NULL, "got %p\n", ctx ); +} + START_TEST(store) { /* various combinations of CertOpenStore */ @@ -3068,4 +3352,9 @@ START_TEST(store) testEmptyStore(); test_I_UpdateStore(); +#ifdef __REACTOS__ + if ((GetVersion() & 0xFF) > 5) // test_PFXImportCertStore() crashes on Server 2003 +#endif + test_PFXImportCertStore(); + test_CryptQueryObject(); } diff --git a/modules/rostests/winetests/crypt32/str.c b/modules/rostests/winetests/crypt32/str.c index d382c0e6b09..1f65234f400 100644 --- a/modules/rostests/winetests/crypt32/str.c +++ b/modules/rostests/winetests/crypt32/str.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "wine/test.h" @@ -31,7 +32,6 @@ typedef struct _CertRDNAttrEncoding { DWORD dwValueType; CERT_RDN_VALUE_BLOB Value; LPCSTR str; - BOOL todo; } CertRDNAttrEncoding, *PCertRDNAttrEncoding; typedef struct _CertRDNAttrEncodingW { @@ -39,7 +39,6 @@ typedef struct _CertRDNAttrEncodingW { DWORD dwValueType; CERT_RDN_VALUE_BLOB Value; LPCWSTR str; - BOOL todo; } CertRDNAttrEncodingW, *PCertRDNAttrEncodingW; static BYTE bin1[] = { 0x55, 0x53 }; @@ -68,6 +67,27 @@ static BYTE bin12[] = { 0x20, 0x61, 0x62, 0x63, 0x20 }; static BYTE bin13[] = { 0x22, 0x64, 0x65, 0x66, 0x22 }; static BYTE bin14[] = { 0x31, 0x3b, 0x33 }; +/* +Certificate: + Data: + Version: 1 (0x0) + Serial Number: + e3:5a:10:f1:fc:4b:f3:a2 + Signature Algorithm: md5WithRSAEncryption + Issuer: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, OU = Wine Development, CN = localhost, emailAddress = aric@codeweavers.com + Validity + Not Before: Jan 25 13:57:24 2006 GMT + Not After : Feb 24 13:57:24 2006 GMT + Subject: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, OU = Wine Development, CN = localhost, emailAddress = aric@codeweavers.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: +... + Exponent: 65537 (0x10001) + Signature Algorithm: md5WithRSAEncryption +... +*/ static const BYTE cert[] = {0x30,0x82,0x2,0xbb,0x30,0x82,0x2,0x24,0x2,0x9,0x0,0xe3,0x5a,0x10,0xf1,0xfc, 0x4b,0xf3,0xa2,0x30,0xd,0x6,0x9,0x2a,0x86,0x48,0x86,0xf7,0xd,0x1,0x1,0x4,0x5, @@ -115,6 +135,167 @@ static const BYTE cert[] = 0x65,0xd3,0xce,0xae,0x26,0x19,0x3,0x2e,0x4f,0x78,0xa5,0xa,0x97,0x7e,0x4f,0xc4, 0x91,0x8a,0xf8,0x5,0xef,0x5b,0x3b,0x49,0xbf,0x5f,0x2b}; +/* +Certificate: + Data: + Version: 1 (0x0) + Serial Number: + 59:9e:db:44:80:da:6c:92:f9:38:be:d8:fe:7a:20:77:57:c7:71:5b + Signature Algorithm: md5WithRSAEncryption + Issuer: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, OU = Wine Development, CN = localhost + Validity + Not Before: Mar 17 22:20:44 2023 GMT + Not After : Apr 16 22:20:44 2023 GMT + Subject: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, OU = Wine Development, CN = localhost + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: +... + Exponent: 65537 (0x10001) + Signature Algorithm: md5WithRSAEncryption +... +*/ +static const BYTE cert_no_email[] = { + 0x30,0x82,0x02,0x7a,0x30,0x82,0x01,0xe3,0x02,0x14,0x59,0x9e,0xdb,0x44,0x80,0xda, + 0x6c,0x92,0xf9,0x38,0xbe,0xd8,0xfe,0x7a,0x20,0x77,0x57,0xc7,0x71,0x5b,0x30,0x0d, + 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,0x30,0x7c,0x31, + 0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10, + 0x06,0x03,0x55,0x04,0x08,0x0c,0x09,0x4d,0x69,0x6e,0x6e,0x65,0x73,0x6f,0x74,0x61, + 0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x07,0x0c,0x0b,0x4d,0x69,0x6e,0x6e,0x65, + 0x61,0x70,0x6f,0x6c,0x69,0x73,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0a,0x0c, + 0x0b,0x43,0x6f,0x64,0x65,0x57,0x65,0x61,0x76,0x65,0x72,0x73,0x31,0x19,0x30,0x17, + 0x06,0x03,0x55,0x04,0x0b,0x0c,0x10,0x57,0x69,0x6e,0x65,0x20,0x44,0x65,0x76,0x65, + 0x6c,0x6f,0x70,0x6d,0x65,0x6e,0x74,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03, + 0x0c,0x09,0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74,0x30,0x1e,0x17,0x0d,0x32, + 0x33,0x30,0x33,0x31,0x37,0x32,0x32,0x32,0x30,0x34,0x34,0x5a,0x17,0x0d,0x32,0x33, + 0x30,0x34,0x31,0x36,0x32,0x32,0x32,0x30,0x34,0x34,0x5a,0x30,0x7c,0x31,0x0b,0x30, + 0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03, + 0x55,0x04,0x08,0x0c,0x09,0x4d,0x69,0x6e,0x6e,0x65,0x73,0x6f,0x74,0x61,0x31,0x14, + 0x30,0x12,0x06,0x03,0x55,0x04,0x07,0x0c,0x0b,0x4d,0x69,0x6e,0x6e,0x65,0x61,0x70, + 0x6f,0x6c,0x69,0x73,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0a,0x0c,0x0b,0x43, + 0x6f,0x64,0x65,0x57,0x65,0x61,0x76,0x65,0x72,0x73,0x31,0x19,0x30,0x17,0x06,0x03, + 0x55,0x04,0x0b,0x0c,0x10,0x57,0x69,0x6e,0x65,0x20,0x44,0x65,0x76,0x65,0x6c,0x6f, + 0x70,0x6d,0x65,0x6e,0x74,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x0c,0x09, + 0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09, + 0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,0x00,0x30, + 0x81,0x89,0x02,0x81,0x81,0x00,0xc4,0xdd,0x00,0xa7,0xdb,0xec,0x95,0x68,0xee,0xf0, + 0x3f,0xed,0xb2,0xcb,0x6f,0xf4,0x34,0x2f,0xbe,0x13,0xa9,0x24,0x95,0xf3,0xca,0x3c, + 0x2b,0xd3,0x41,0x7c,0x32,0xe7,0x95,0x4e,0xdd,0xef,0xcc,0x45,0x0d,0xf2,0x71,0x42, + 0x12,0x78,0xb1,0x17,0x88,0xf4,0x12,0xba,0x92,0x2d,0x5c,0xfc,0x2c,0x8a,0x53,0xbf, + 0xee,0x23,0x3f,0x7b,0x11,0x46,0x5e,0x1d,0xb8,0xff,0xa3,0x70,0x5c,0x5f,0x6b,0xa8, + 0x3c,0x47,0x75,0xa5,0x3a,0x80,0x61,0x15,0x10,0x56,0x57,0x1f,0x82,0x6a,0xb2,0xb8, + 0xdc,0x3a,0xe0,0x1c,0x9c,0x83,0xd9,0x11,0x26,0xa6,0xb6,0x85,0x0a,0x27,0x45,0xb7, + 0xff,0xfa,0x26,0xbd,0x11,0x29,0x23,0x59,0xaa,0x19,0x77,0x3f,0x86,0x32,0x9f,0x48, + 0x43,0x4f,0xd0,0x03,0x7a,0x09,0x02,0x03,0x01,0x00,0x01,0x30,0x0d,0x06,0x09,0x2a, + 0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0xa3,0xf0, + 0x23,0xfc,0x80,0x05,0xac,0x76,0x26,0xbb,0xfc,0x79,0x03,0x10,0xa0,0xfb,0x7a,0x3e, + 0xf9,0xa7,0xdd,0xb1,0x9e,0x7c,0x22,0x83,0xa6,0xee,0x77,0x88,0xa2,0x74,0x64,0x35, + 0x4f,0x66,0x82,0x88,0x4a,0x83,0xc9,0xda,0x7e,0xc4,0xa0,0xd1,0xfb,0xe1,0x3e,0x22, + 0x1e,0xa8,0xdc,0x1b,0xd4,0xda,0x64,0x63,0xfc,0x1b,0x61,0x4f,0x52,0x1b,0xab,0x61, + 0x05,0xcd,0xb8,0x2d,0xb0,0x73,0xa7,0x5d,0x78,0xff,0x3f,0x4d,0x12,0x3a,0x38,0x69, + 0xc4,0x9f,0x77,0x35,0xce,0xe2,0xf9,0xd6,0x23,0x47,0xc2,0x15,0xff,0xbf,0x3e,0x65, + 0xf3,0xc0,0x0a,0x58,0x76,0x10,0x8e,0xd5,0xa9,0x30,0x3e,0x25,0x4b,0x6d,0xb7,0xb2, + 0x64,0x96,0x0e,0x27,0x88,0x55,0xfc,0xaa,0x18,0x65,0x2a,0xe9,0xf4,0x23 +}; + +/* +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 5d:79:35:fd:d3:8f:6b:e2:28:3e:94:f4:14:bf:d4:b5:c2:3a:ac:38 + Signature Algorithm: md5WithRSAEncryption + Issuer: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, CN = server_cn.org, emailAddress = test@codeweavers.com + Validity + Not Before: Apr 14 18:56:22 2022 GMT + Not After : Apr 11 18:56:22 2032 GMT + Subject: C = US, ST = Minnesota, L = Minneapolis, O = CodeWeavers, CN = server_cn.org, emailAddress = test@codeweavers.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public-Key: (1024 bit) + Modulus: +... + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Alternative Name: + DNS:ex1.org, DNS:*.ex2.org + X509v3 Issuer Alternative Name: + DNS:ex3.org, DNS:*.ex4.org + Signature Algorithm: md5WithRSAEncryption +... +*/ +static BYTE cert_v3[] = { + 0x30, 0x82, 0x02, 0xdf, 0x30, 0x82, 0x02, 0x48, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x14, 0x5d, 0x79, 0x35, 0xfd, 0xd3, 0x8f, 0x6b, 0xe2, 0x28, + 0x3e, 0x94, 0xf4, 0x14, 0xbf, 0xd4, 0xb5, 0xc2, 0x3a, 0xac, 0x38, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x04, + 0x05, 0x00, 0x30, 0x81, 0x8a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, + 0x55, 0x04, 0x08, 0x0c, 0x09, 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x73, 0x6f, + 0x74, 0x61, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, + 0x0b, 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x61, 0x70, 0x6f, 0x6c, 0x69, 0x73, + 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x43, + 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x31, 0x16, + 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0d, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x5f, 0x63, 0x6e, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x23, + 0x30, 0x21, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, + 0x01, 0x16, 0x14, 0x74, 0x65, 0x73, 0x74, 0x40, 0x63, 0x6f, 0x64, 0x65, + 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x30, + 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x34, 0x31, 0x34, 0x31, 0x38, 0x35, + 0x36, 0x32, 0x32, 0x5a, 0x17, 0x0d, 0x33, 0x32, 0x30, 0x34, 0x31, 0x31, + 0x31, 0x38, 0x35, 0x36, 0x32, 0x32, 0x5a, 0x30, 0x81, 0x8a, 0x31, 0x0b, + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, + 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x09, 0x4d, 0x69, + 0x6e, 0x6e, 0x65, 0x73, 0x6f, 0x74, 0x61, 0x31, 0x14, 0x30, 0x12, 0x06, + 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0b, 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x61, + 0x70, 0x6f, 0x6c, 0x69, 0x73, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, + 0x04, 0x0a, 0x0c, 0x0b, 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, 0x76, + 0x65, 0x72, 0x73, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x03, + 0x0c, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x63, 0x6e, 0x2e, + 0x6f, 0x72, 0x67, 0x31, 0x23, 0x30, 0x21, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x14, 0x74, 0x65, 0x73, 0x74, + 0x40, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, + 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xcd, 0x7c, 0x05, + 0xba, 0xad, 0xd0, 0xb0, 0x43, 0xcc, 0x47, 0x7d, 0x87, 0xaa, 0xb5, 0x89, + 0x9f, 0x43, 0x94, 0xa0, 0x84, 0xc0, 0xc0, 0x5e, 0x05, 0x6d, 0x2f, 0x05, + 0x21, 0x6b, 0x20, 0x39, 0x88, 0x06, 0x4e, 0xce, 0x76, 0xa7, 0x24, 0x77, + 0x13, 0x71, 0x9b, 0x2a, 0x53, 0x04, 0x4f, 0x0f, 0xfc, 0x3f, 0x4f, 0xb1, + 0x4e, 0xdc, 0xed, 0x96, 0xd4, 0x55, 0xbd, 0xcf, 0x25, 0xa6, 0x7c, 0xe3, + 0x35, 0xbf, 0xeb, 0x30, 0xec, 0xef, 0x7f, 0x8e, 0xa1, 0xc6, 0xd3, 0xb2, + 0x03, 0x62, 0x0a, 0x92, 0x87, 0x17, 0x52, 0x2d, 0x45, 0x2a, 0xdc, 0xdb, + 0x87, 0xa5, 0x32, 0x4a, 0x78, 0x28, 0x4a, 0x51, 0xff, 0xdb, 0xd5, 0x20, + 0x47, 0x7e, 0xc5, 0xbe, 0x1d, 0x01, 0x55, 0x13, 0x9f, 0xfb, 0x8e, 0x39, + 0xd9, 0x1b, 0xe0, 0x34, 0x93, 0x43, 0x9c, 0x02, 0xa3, 0x0f, 0xb5, 0xdc, + 0x9d, 0x86, 0x45, 0xc5, 0x4d, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x40, + 0x30, 0x3e, 0x30, 0x1d, 0x06, 0x03, + 0x55, 0x1d, 0x11, /* Subject Alternative Name OID */ + 0x04, 0x16, 0x30, 0x14, 0x82, 0x07, 0x65, 0x78, 0x31, 0x2e, 0x6f, 0x72, + 0x67, 0x82, 0x09, 0x2a, 0x2e, 0x65, 0x78, 0x32, 0x2e, 0x6f, 0x72, 0x67, + 0x30, 0x1d, 0x06, 0x03, + 0x55, 0x1d, 0x12, /* Issuer Alternative Name OID */ + 0x04, 0x16, 0x30, 0x14, 0x82, 0x07, 0x65, 0x78, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x82, 0x09, 0x2a, 0x2e, 0x65, 0x78, 0x34, 0x2e, 0x6f, 0x72, 0x67, + 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x04, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0xcc, 0xa3, 0x75, 0x67, 0x61, + 0x63, 0x1d, 0x99, 0x16, 0xc6, 0x93, 0x35, 0xa4, 0x31, 0xb6, 0x05, 0x05, + 0x77, 0x12, 0x15, 0x16, 0x78, 0xb3, 0xba, 0x6e, 0xde, 0xfc, 0x73, 0x7c, + 0x5c, 0xdd, 0xdf, 0x92, 0xde, 0xa0, 0x86, 0xff, 0x77, 0x60, 0x99, 0x8f, + 0x4a, 0x40, 0xa8, 0x6a, 0xdb, 0x6f, 0x30, 0xe5, 0xce, 0x82, 0x2f, 0xf7, + 0x09, 0x17, 0xb2, 0xd3, 0x3a, 0x29, 0x9a, 0xd0, 0x73, 0x9c, 0x44, 0xa2, + 0x19, 0xf3, 0x1d, 0x16, 0x1a, 0x45, 0x2c, 0x4b, 0x94, 0xf1, 0xb8, 0xb6, + 0xc9, 0x82, 0x6c, 0x1f, 0xae, 0xbc, 0xd1, 0xbe, 0x78, 0xc9, 0x23, 0xf5, + 0x51, 0x6c, 0x90, 0xbf, 0xa3, 0x5c, 0xa1, 0x3a, 0xd8, 0xe3, 0xcf, 0x82, + 0x31, 0x78, 0x2b, 0xda, 0x99, 0xff, 0x23, 0x5b, 0xea, 0x59, 0xe0, 0x6d, + 0xd1, 0x30, 0xfd, 0x96, 0x6a, 0x4d, 0x36, 0x72, 0x96, 0xd7, 0x4f, 0x01, + 0xa9, 0x4d, 0x8f +}; + +#define CERT_V3_SAN_OID_OFFSET 534 +#define CERT_V3_IAN_OID_OFFSET 565 + static char issuerStr[] = "US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric@codeweavers.com"; static char issuerStrSemicolon[] = @@ -129,262 +310,176 @@ static char subjectStrCRLF[] = "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"; static char x500SubjectStr[] = "C=US, S=Minnesota, L=Minneapolis, O=CodeWeavers, OU=Wine Development, CN=localhost, E=aric@codeweavers.com"; static char x500SubjectStrSemicolonReverse[] = "E=aric@codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; C=US"; -static WCHAR issuerStrW[] = { - 'U','S',',',' ','M','i','n','n','e','s','o','t','a',',',' ','M','i','n','n', - 'e','a','p','o','l','i','s',',',' ','C','o','d','e','W','e','a','v','e','r', - 's',',',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t', - ',',' ','l','o','c','a','l','h','o','s','t',',',' ','a','r','i','c','@','c', - 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR issuerStrSemicolonW[] = { - 'U','S',';',' ','M','i','n','n','e','s','o','t','a',';',' ','M','i','n','n', - 'e','a','p','o','l','i','s',';',' ','C','o','d','e','W','e','a','v','e','r', - 's',';',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t', - ';',' ','l','o','c','a','l','h','o','s','t',';',' ','a','r','i','c','@','c', - 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR issuerStrCRLFW[] = { - 'U','S','\r','\n','M','i','n','n','e','s','o','t','a','\r','\n','M','i','n', - 'n','e','a','p','o','l','i','s','\r','\n','C','o','d','e','W','e','a','v','e', - 'r','s','\r','\n','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n', - 't','\r','\n','l','o','c','a','l','h','o','s','t','\r','\n','a','r','i','c', - '@','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrW[] = { - '2','.','5','.','4','.','6','=','U','S',',',' ','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a',',',' ','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s',',',' ','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',',',' ','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t',',',' ','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t',',',' ','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrSemicolonW[] = { - '2','.','5','.','4','.','6','=','U','S',';',' ','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a',';',' ','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s',';',' ','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',';',' ','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t',';',' ','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t',';',' ','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR subjectStrCRLFW[] = { - '2','.','5','.','4','.','6','=','U','S','\r','\n','2','.','5','.','4','.','8', - '=','M','i','n','n','e','s','o','t','a','\r','\n','2','.','5','.','4','.','7', - '=','M','i','n','n','e','a','p','o','l','i','s','\r','\n','2','.','5','.','4', - '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s','\r','\n','2','.', - '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p', - 'm','e','n','t','\r','\n','2','.','5','.','4','.','3','=','l','o','c','a','l', - 'h','o','s','t','\r','\n','1','.','2','.','8','4','0','.','1','1','3','5','4', - '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; -static WCHAR x500SubjectStrSemicolonReverseW[] = { - 'E','=','a','r','i','c','@','c','o','d','e','w','e','a','v','e','r','s','.','c', - 'o','m',';',' ','C','N','=','l','o','c','a','l','h','o','s','t',';',' ','O','U', - '=','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t',';',' ','O', - '=','C','o','d','e','W','e','a','v','e','r','s',';',' ','L','=','M','i','n','n', - 'e','a','p','o','l','i','s',';',' ','S','=','M','i','n','n','e','s','o','t','a', - ';',' ','C','=','U','S',0 }; - -static HMODULE dll; -static DWORD (WINAPI *pCertNameToStrA)(DWORD,LPVOID,DWORD,LPSTR,DWORD); -static DWORD (WINAPI *pCertNameToStrW)(DWORD,LPVOID,DWORD,LPWSTR,DWORD); -static DWORD (WINAPI *pCertRDNValueToStrA)(DWORD, PCERT_RDN_VALUE_BLOB, - LPSTR, DWORD); -static DWORD (WINAPI *pCertRDNValueToStrW)(DWORD, PCERT_RDN_VALUE_BLOB, - LPWSTR, DWORD); -static BOOL (WINAPI *pCertStrToNameA)(DWORD dwCertEncodingType, - LPCSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, - DWORD *pcbEncoded, LPCSTR *ppszError); -static BOOL (WINAPI *pCertStrToNameW)(DWORD dwCertEncodingType, - LPCWSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, - DWORD *pcbEncoded, LPCWSTR *ppszError); -static DWORD (WINAPI *pCertGetNameStringA)(PCCERT_CONTEXT cert, DWORD type, - DWORD flags, void *typePara, LPSTR str, DWORD cch); - static void test_CertRDNValueToStrA(void) { CertRDNAttrEncoding attrs[] = { { "2.5.4.6", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin1), bin1 }, "US", FALSE }, + { sizeof(bin1), bin1 }, "US" }, { "2.5.4.8", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin2), bin2 }, "Minnesota", FALSE }, + { sizeof(bin2), bin2 }, "Minnesota" }, { "2.5.4.7", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin3), bin3 }, "Minneapolis", FALSE }, + { sizeof(bin3), bin3 }, "Minneapolis" }, { "2.5.4.10", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin4), bin4 }, "CodeWeavers", FALSE }, + { sizeof(bin4), bin4 }, "CodeWeavers" }, { "2.5.4.11", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin5), bin5 }, "Wine Development", FALSE }, + { sizeof(bin5), bin5 }, "Wine Development" }, { "2.5.4.3", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin6), bin6 }, "localhost", FALSE }, + { sizeof(bin6), bin6 }, "localhost" }, { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING, - { sizeof(bin7), bin7 }, "aric@codeweavers.com", FALSE }, + { sizeof(bin7), bin7 }, "aric@codeweavers.com" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin9), bin9 }, "abc\"def", FALSE }, + { sizeof(bin9), bin9 }, "abc\"def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin10), bin10 }, "abc'def", FALSE }, + { sizeof(bin10), bin10 }, "abc'def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin11), bin11 }, "abc, def", FALSE }, + { sizeof(bin11), bin11 }, "abc, def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin12), bin12 }, " abc ", FALSE }, + { sizeof(bin12), bin12 }, " abc " }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin13), bin13 }, "\"def\"", FALSE }, + { sizeof(bin13), bin13 }, "\"def\"" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin14), bin14 }, "1;3", FALSE }, + { sizeof(bin14), bin14 }, "1;3" }, }; - DWORD i, ret; + unsigned int i; + DWORD ret, len; char buffer[2000]; CERT_RDN_VALUE_BLOB blob = { 0, NULL }; static const char ePKI[] = "ePKI Root Certification Authority"; - if (!pCertRDNValueToStrA) return; - /* This crashes - ret = pCertRDNValueToStrA(0, NULL, NULL, 0); + ret = CertRDNValueToStrA(0, NULL, NULL, 0); */ /* With empty input, it generates the empty string */ SetLastError(0xdeadbeef); - ret = pCertRDNValueToStrA(0, &blob, NULL, 0); + ret = CertRDNValueToStrA(0, &blob, NULL, 0); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); - ret = pCertRDNValueToStrA(0, &blob, buffer, sizeof(buffer)); + ret = CertRDNValueToStrA(0, &blob, buffer, sizeof(buffer)); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n"); for (i = 0; i < ARRAY_SIZE(attrs); i++) { - ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, + len = CertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, buffer, sizeof(buffer)); - todo_wine_if (attrs[i].todo) - { - ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %d\n", - lstrlenA(attrs[i].str) + 1, ret); - ok(!strcmp(buffer, attrs[i].str), "Expected %s, got %s\n", - attrs[i].str, buffer); - } + ok(len == strlen(attrs[i].str) + 1, "Expected length %d, got %ld\n", + lstrlenA(attrs[i].str) + 1, ret); + ok(!strcmp(buffer, attrs[i].str), "Expected %s, got %s\n", + attrs[i].str, buffer); + memset(buffer, 0xcc, sizeof(buffer)); + ret = CertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, buffer, len - 1); + ok(ret == 1, "Unexpected ret %lu, expected 1, test %u.\n", ret, i); + ok(!buffer[0], "Unexpected value %#x, test %u.\n", buffer[0], i); + ok(!strncmp(buffer + 1, attrs[i].str + 1, len - 2), "Strings do not match, test %u.\n", i); + memset(buffer, 0xcc, sizeof(buffer)); + ret = CertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, buffer, 0); + ok(ret == len, "Unexpected ret %lu, expected %lu, test %u.\n", ret, len, i); + ok((unsigned char)buffer[0] == 0xcc, "Unexpected value %#x, test %u.\n", buffer[0], i); } blob.pbData = bin8; blob.cbData = sizeof(bin8); - ret = pCertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer, + ret = CertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer, sizeof(buffer)); - ok(ret == strlen(ePKI) + 1 || broken(ret != strlen(ePKI) + 1), - "Expected length %d, got %d\n", lstrlenA(ePKI), ret); + ok(ret == strlen(ePKI) + 1, "Expected length %d, got %ld\n", lstrlenA(ePKI), ret); if (ret == strlen(ePKI) + 1) ok(!strcmp(buffer, ePKI), "Expected %s, got %s\n", ePKI, buffer); } static void test_CertRDNValueToStrW(void) { - static const WCHAR usW[] = { 'U','S',0 }; - static const WCHAR minnesotaW[] = { 'M','i','n','n','e','s','o','t','a',0 }; - static const WCHAR minneapolisW[] = { 'M','i','n','n','e','a','p','o','l', - 'i','s',0 }; - static const WCHAR codeweaversW[] = { 'C','o','d','e','W','e','a','v','e', - 'r','s',0 }; - static const WCHAR wineDevW[] = { 'W','i','n','e',' ','D','e','v','e','l', - 'o','p','m','e','n','t',0 }; - static const WCHAR localhostW[] = { 'l','o','c','a','l','h','o','s','t',0 }; - static const WCHAR aricW[] = { 'a','r','i','c','@','c','o','d','e','w','e', - 'a','v','e','r','s','.','c','o','m',0 }; - static const WCHAR ePKIW[] = { 'e','P','K','I',' ','R','o','o','t',' ', - 'C','e','r','t','i','f','i','c','a','t','i','o','n',' ','A','u','t','h', - 'o','r','i','t','y',0 }; - static const WCHAR embeddedDoubleQuoteW[] = { 'a','b','c','"','d','e','f', - 0 }; - static const WCHAR embeddedSingleQuoteW[] = { 'a','b','c','\'','d','e','f', - 0 }; - static const WCHAR embeddedCommaW[] = { 'a','b','c',',',' ','d','e','f',0 }; - static const WCHAR trailingAndEndingSpaceW[] = { ' ','a','b','c',' ',0 }; - static const WCHAR enclosingQuotesW[] = { '"','d','e','f','"',0 }; - static const WCHAR embeddedSemiW[] = { '1',';','3',0 }; + static const WCHAR ePKIW[] = L"ePKI Root Certification Authority"; CertRDNAttrEncodingW attrs[] = { { "2.5.4.6", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin1), bin1 }, usW, FALSE }, + { sizeof(bin1), bin1 }, L"US" }, { "2.5.4.8", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin2), bin2 }, minnesotaW, FALSE }, + { sizeof(bin2), bin2 }, L"Minnesota" }, { "2.5.4.7", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin3), bin3 }, minneapolisW, FALSE }, + { sizeof(bin3), bin3 }, L"Minneapolis" }, { "2.5.4.10", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin4), bin4 }, codeweaversW, FALSE }, + { sizeof(bin4), bin4 }, L"CodeWeavers" }, { "2.5.4.11", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin5), bin5 }, wineDevW, FALSE }, + { sizeof(bin5), bin5 }, L"Wine Development" }, { "2.5.4.3", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin6), bin6 }, localhostW, FALSE }, + { sizeof(bin6), bin6 }, L"localhost" }, { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING, - { sizeof(bin7), bin7 }, aricW, FALSE }, + { sizeof(bin7), bin7 }, L"aric@codeweavers.com" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin9), bin9 }, embeddedDoubleQuoteW, FALSE }, + { sizeof(bin9), bin9 }, L"abc\"def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin10), bin10 }, embeddedSingleQuoteW, FALSE }, + { sizeof(bin10), bin10 }, L"abc'def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin11), bin11 }, embeddedCommaW, FALSE }, + { sizeof(bin11), bin11 }, L"abc, def" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin12), bin12 }, trailingAndEndingSpaceW, FALSE }, + { sizeof(bin12), bin12 }, L" abc " }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin13), bin13 }, enclosingQuotesW, FALSE }, + { sizeof(bin13), bin13 }, L"\"def\"" }, { "0", CERT_RDN_PRINTABLE_STRING, - { sizeof(bin14), bin14 }, embeddedSemiW, FALSE }, + { sizeof(bin14), bin14 }, L"1;3" }, }; - DWORD i, ret; + unsigned int i; + DWORD ret, len; WCHAR buffer[2000]; CERT_RDN_VALUE_BLOB blob = { 0, NULL }; - if (!pCertRDNValueToStrW) - { - win_skip("CertRDNValueToStrW is not available\n"); - return; - } - /* This crashes - ret = pCertRDNValueToStrW(0, NULL, NULL, 0); + ret = CertRDNValueToStrW(0, NULL, NULL, 0); */ /* With empty input, it generates the empty string */ SetLastError(0xdeadbeef); - ret = pCertRDNValueToStrW(0, &blob, NULL, 0); + ret = CertRDNValueToStrW(0, &blob, NULL, 0); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); - ret = pCertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer)); + ret = CertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer)); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n"); for (i = 0; i < ARRAY_SIZE(attrs); i++) { - ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer)); - todo_wine_if (attrs[i].todo) - { - ok(ret == lstrlenW(attrs[i].str) + 1, - "Expected length %d, got %d\n", lstrlenW(attrs[i].str) + 1, ret); - ok(!lstrcmpW(buffer, attrs[i].str), "Expected %s, got %s\n", - wine_dbgstr_w(attrs[i].str), wine_dbgstr_w(buffer)); - } + len = CertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer)); + ok(len == lstrlenW(attrs[i].str) + 1, + "Expected length %d, got %ld\n", lstrlenW(attrs[i].str) + 1, ret); + ok(!lstrcmpW(buffer, attrs[i].str), "Expected %s, got %s\n", + wine_dbgstr_w(attrs[i].str), wine_dbgstr_w(buffer)); + memset(buffer, 0xcc, sizeof(buffer)); + ret = CertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, len - 1); + ok(ret == 1, "Unexpected ret %lu, expected 1, test %u.\n", ret, i); + ok(!buffer[0], "Unexpected value %#x, test %u.\n", buffer[0], i); + ok(buffer[1] == 0xcccc, "Unexpected value %#x, test %u.\n", buffer[1], i); + memset(buffer, 0xcc, sizeof(buffer)); + ret = CertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, 0); + ok(ret == len, "Unexpected ret %lu, expected %lu, test %u.\n", ret, len, i); + ok(buffer[0] == 0xcccc, "Unexpected value %#x, test %u.\n", buffer[0], i); } blob.pbData = bin8; blob.cbData = sizeof(bin8); - ret = pCertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer, + ret = CertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer, sizeof(buffer)); - ok(ret == lstrlenW(ePKIW) + 1 || broken(ret != lstrlenW(ePKIW) + 1), - "Expected length %d, got %d\n", lstrlenW(ePKIW), ret); + ok(ret == lstrlenW(ePKIW) + 1, "Expected length %d, got %ld\n", lstrlenW(ePKIW), ret); if (ret == lstrlenW(ePKIW) + 1) ok(!lstrcmpW(buffer, ePKIW), "Expected %s, got %s\n", wine_dbgstr_w(ePKIW), wine_dbgstr_w(buffer)); } -static void test_NameToStrConversionA(PCERT_NAME_BLOB pName, DWORD dwStrType, - LPCSTR expected, BOOL todo) +#define test_NameToStrConversionA(a, b, c) test_NameToStrConversionA_(__LINE__, a, b, c) +static void test_NameToStrConversionA_(unsigned int line, PCERT_NAME_BLOB pName, DWORD dwStrType, LPCSTR expected) { - char buffer[2000] = { 0 }; - DWORD i; + char buffer[2000]; + DWORD len, retlen; - i = pCertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0); - todo_wine_if (todo) - ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n", - lstrlenA(expected) + 1, i); - i = pCertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer, - sizeof(buffer)); - todo_wine_if (todo) - ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n", - lstrlenA(expected) + 1, i); - todo_wine_if (todo) - ok(!strcmp(buffer, expected), "Expected %s, got %s\n", expected, - buffer); + len = CertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0); + ok(len == strlen(expected) + 1, "line %u: Expected %d chars, got %ld.\n", line, lstrlenA(expected) + 1, len); + len = CertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer, sizeof(buffer)); + ok(len == strlen(expected) + 1, "line %u: Expected %d chars, got %ld.\n", line, lstrlenA(expected) + 1, len); + ok(!strcmp(buffer, expected), "line %u: Expected %s, got %s.\n", line, expected, buffer); + + memset(buffer, 0xcc, sizeof(buffer)); + retlen = CertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, buffer, len - 1); + ok(retlen == 1, "line %u: expected 1, got %lu\n", line, retlen); + ok(!buffer[0], "line %u: string is not zero terminated.\n", line); + + memset(buffer, 0xcc, sizeof(buffer)); + retlen = CertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, buffer, 0); + ok(retlen == len, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen); + ok((unsigned char)buffer[0] == 0xcc, "line %u: got %s\n", line, wine_dbgstr_a(buffer)); } static BYTE encodedSimpleCN[] = { @@ -433,273 +528,228 @@ static void test_CertNameToStrA(void) PCCERT_CONTEXT context; CERT_NAME_BLOB blob; - if (!pCertNameToStrA) - { - win_skip("CertNameToStrA is not available\n"); - return; - } - context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); if (context) { DWORD ret; /* This crashes - ret = pCertNameToStrA(0, NULL, 0, NULL, 0); + ret = CertNameToStrA(0, NULL, 0, NULL, 0); */ /* Test with a bogus encoding type */ SetLastError(0xdeadbeef); - ret = pCertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0); + ret = CertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n", + "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); - ret = pCertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer, + ret = CertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected positive return and ERROR_SUCCESS, got %d - %08x\n", + "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n", ret, GetLastError()); + test_NameToStrConversionA(&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR, issuerStr); test_NameToStrConversionA(&context->pCertInfo->Issuer, - CERT_SIMPLE_NAME_STR, issuerStr, FALSE); + CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, issuerStrSemicolon); test_NameToStrConversionA(&context->pCertInfo->Issuer, - CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - issuerStrSemicolon, FALSE); - test_NameToStrConversionA(&context->pCertInfo->Issuer, - CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - issuerStrCRLF, FALSE); + CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG, issuerStrCRLF); + test_NameToStrConversionA(&context->pCertInfo->Subject, CERT_OID_NAME_STR, subjectStr); test_NameToStrConversionA(&context->pCertInfo->Subject, - CERT_OID_NAME_STR, subjectStr, FALSE); + CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, subjectStrSemicolon); test_NameToStrConversionA(&context->pCertInfo->Subject, - CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - subjectStrSemicolon, FALSE); + CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG, subjectStrCRLF); test_NameToStrConversionA(&context->pCertInfo->Subject, - CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - subjectStrCRLF, FALSE); - test_NameToStrConversionA(&context->pCertInfo->Subject, - CERT_X500_NAME_STR, x500SubjectStr, FALSE); + CERT_X500_NAME_STR, x500SubjectStr); test_NameToStrConversionA(&context->pCertInfo->Subject, CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG, - x500SubjectStrSemicolonReverse, FALSE); + x500SubjectStrSemicolonReverse); CertFreeCertificateContext(context); } blob.pbData = encodedSimpleCN; blob.cbData = sizeof(encodedSimpleCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=1", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=1"); blob.pbData = encodedSingleQuotedCN; blob.cbData = sizeof(encodedSingleQuotedCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN='1'", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "'1'", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN='1'"); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "'1'"); blob.pbData = encodedSpacedCN; blob.cbData = sizeof(encodedSpacedCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\" 1 \"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\" 1 \"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\" 1 \""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\" 1 \""); blob.pbData = encodedQuotedCN; blob.cbData = sizeof(encodedQuotedCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"\"\"1\"\"\"", - FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"\"\"1\"\"\"", - FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"\"\"1\"\"\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"\"\"1\"\"\""); blob.pbData = encodedMultipleAttrCN; blob.cbData = sizeof(encodedMultipleAttrCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"1+2\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"1+2\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"1+2\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"1+2\""); blob.pbData = encodedCommaCN; blob.cbData = sizeof(encodedCommaCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a,b\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a,b\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a,b\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a,b\""); blob.pbData = encodedEqualCN; blob.cbData = sizeof(encodedEqualCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a=b\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a=b\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a=b\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a=b\""); blob.pbData = encodedLessThanCN; blob.cbData = sizeof(encodedLessThanCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"<\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"<\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"<\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"<\""); blob.pbData = encodedGreaterThanCN; blob.cbData = sizeof(encodedGreaterThanCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\">\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\">\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\">\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\">\""); blob.pbData = encodedHashCN; blob.cbData = sizeof(encodedHashCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"#\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"#\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"#\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"#\""); blob.pbData = encodedSemiCN; blob.cbData = sizeof(encodedSemiCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\";\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\";\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\";\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\";\""); blob.pbData = encodedNewlineCN; blob.cbData = sizeof(encodedNewlineCN); - test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a\nb\"", FALSE); - test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a\nb\"", FALSE); + test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a\nb\""); + test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a\nb\""); } -static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType, - LPCWSTR expected, BOOL todo) +#define test_NameToStrConversionW(a, b, c) test_NameToStrConversionW_(__LINE__, a, b, c) +static void test_NameToStrConversionW_(unsigned int line, PCERT_NAME_BLOB pName, DWORD dwStrType, LPCWSTR expected) { - WCHAR buffer[2000] = { 0 }; - DWORD i; + DWORD len, retlen, expected_len; + WCHAR buffer[2000]; - i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0); - todo_wine_if (todo) - ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n", - lstrlenW(expected) + 1, i); - i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer)); - todo_wine_if (todo) - ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n", - lstrlenW(expected) + 1, i); - todo_wine_if (todo) - ok(!lstrcmpW(buffer, expected), "Expected %s, got %s\n", - wine_dbgstr_w(expected), wine_dbgstr_w(buffer)); + expected_len = wcslen(expected) + 1; + memset(buffer, 0xcc, sizeof(buffer)); + len = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, NULL, 0); + ok(len == expected_len, "line %u: expected %lu chars, got %lu\n", line, expected_len, len); + retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, ARRAY_SIZE(buffer)); + ok(retlen == len, "line %u: expected %lu chars, got %lu.\n", line, len, retlen); + ok(!wcscmp(buffer, expected), "Expected %s, got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(buffer)); + + memset(buffer, 0xcc, sizeof(buffer)); + retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, len - 1); + ok(retlen == len - 1, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen); + ok(!wcsncmp(buffer, expected, retlen - 1), "line %u: expected %s, got %s\n", + line, wine_dbgstr_w(expected), wine_dbgstr_w(buffer)); + ok(!buffer[retlen - 1], "line %u: string is not zero terminated.\n", line); + + memset(buffer, 0xcc, sizeof(buffer)); + retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, 0); + ok(retlen == len, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen); + ok(buffer[0] == 0xcccc, "line %u: got %s\n", line, wine_dbgstr_w(buffer)); } -static const WCHAR simpleCN_W[] = { 'C','N','=','1',0 }; -static const WCHAR singledQuotedCN_W[] = { 'C','N','=','\'','1','\'',0 }; -static const WCHAR simpleSingleQuotedCN_W[] = { '\'','1','\'',0 }; -static const WCHAR spacedCN_W[] = { 'C','N','=','"',' ','1',' ','"',0 }; -static const WCHAR simpleSpacedCN_W[] = { '"',' ','1',' ','"',0 }; -static const WCHAR quotedCN_W[] = { 'C','N','=','"','"','"','1','"','"','"',0 }; -static const WCHAR simpleQuotedCN_W[] = { '"','"','"','1','"','"','"',0 }; -static const WCHAR multipleAttrCN_W[] = { 'C','N','=','"','1','+','2','"',0 }; -static const WCHAR simpleMultipleAttrCN_W[] = { '"','1','+','2','"',0 }; -static const WCHAR commaCN_W[] = { 'C','N','=','"','a',',','b','"',0 }; -static const WCHAR simpleCommaCN_W[] = { '"','a',',','b','"',0 }; -static const WCHAR equalCN_W[] = { 'C','N','=','"','a','=','b','"',0 }; -static const WCHAR simpleEqualCN_W[] = { '"','a','=','b','"',0 }; -static const WCHAR lessThanCN_W[] = { 'C','N','=','"','<','"',0 }; -static const WCHAR simpleLessThanCN_W[] = { '"','<','"',0 }; -static const WCHAR greaterThanCN_W[] = { 'C','N','=','"','>','"',0 }; -static const WCHAR simpleGreaterThanCN_W[] = { '"','>','"',0 }; -static const WCHAR hashCN_W[] = { 'C','N','=','"','#','"',0 }; -static const WCHAR simpleHashCN_W[] = { '"','#','"',0 }; -static const WCHAR semiCN_W[] = { 'C','N','=','"',';','"',0 }; -static const WCHAR simpleSemiCN_W[] = { '"',';','"',0 }; -static const WCHAR newlineCN_W[] = { 'C','N','=','"','a','\n','b','"',0 }; -static const WCHAR simpleNewlineCN_W[] = { '"','a','\n','b','"',0 }; - static void test_CertNameToStrW(void) { PCCERT_CONTEXT context; CERT_NAME_BLOB blob; - if (!pCertNameToStrW) - { - win_skip("CertNameToStrW is not available\n"); - return; - } - context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", + ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); if (context) { DWORD ret; /* This crashes - ret = pCertNameToStrW(0, NULL, 0, NULL, 0); + ret = CertNameToStrW(0, NULL, 0, NULL, 0); */ /* Test with a bogus encoding type */ SetLastError(0xdeadbeef); - ret = pCertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0); + ret = CertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n", + "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n", ret, GetLastError()); SetLastError(0xdeadbeef); - ret = pCertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer, + ret = CertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer, 0, NULL, 0); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected positive return and ERROR_SUCCESS, got %d - %08x\n", + "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n", ret, GetLastError()); test_NameToStrConversionW(&context->pCertInfo->Issuer, - CERT_SIMPLE_NAME_STR, issuerStrW, FALSE); + CERT_SIMPLE_NAME_STR, + L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric@codeweavers.com"); test_NameToStrConversionW(&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - issuerStrSemicolonW, FALSE); + L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric@codeweavers.com"); test_NameToStrConversionW(&context->pCertInfo->Issuer, CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - issuerStrCRLFW, FALSE); + L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric@codeweavers.com"); test_NameToStrConversionW(&context->pCertInfo->Subject, - CERT_OID_NAME_STR, subjectStrW, FALSE); + CERT_OID_NAME_STR, + L"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"); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG, - subjectStrSemicolonW, FALSE); + L"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"); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG, - subjectStrCRLFW, FALSE); + L"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"); test_NameToStrConversionW(&context->pCertInfo->Subject, CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG, - x500SubjectStrSemicolonReverseW, FALSE); + L"E=aric@codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; " + "C=US"); CertFreeCertificateContext(context); } blob.pbData = encodedSimpleCN; blob.cbData = sizeof(encodedSimpleCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, simpleCN_W, FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1"); blob.pbData = encodedSingleQuotedCN; blob.cbData = sizeof(encodedSingleQuotedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, singledQuotedCN_W, - FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleSingleQuotedCN_W, FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'"); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"'1'"); blob.pbData = encodedSpacedCN; blob.cbData = sizeof(encodedSpacedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, spacedCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSpacedCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\" 1 \""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\" 1 \""); blob.pbData = encodedQuotedCN; blob.cbData = sizeof(encodedQuotedCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, quotedCN_W, - FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleQuotedCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"\"\"1\"\"\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"\"\"1\"\"\""); blob.pbData = encodedMultipleAttrCN; blob.cbData = sizeof(encodedMultipleAttrCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, multipleAttrCN_W, - FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleMultipleAttrCN_W, FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"1+2\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"1+2\""); blob.pbData = encodedCommaCN; blob.cbData = sizeof(encodedCommaCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, commaCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleCommaCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a,b\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a,b\""); blob.pbData = encodedEqualCN; blob.cbData = sizeof(encodedEqualCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, equalCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleEqualCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a=b\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a=b\""); blob.pbData = encodedLessThanCN; blob.cbData = sizeof(encodedLessThanCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, lessThanCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleLessThanCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"<\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"<\""); blob.pbData = encodedGreaterThanCN; blob.cbData = sizeof(encodedGreaterThanCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, greaterThanCN_W, - FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, - simpleGreaterThanCN_W, FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\">\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\">\""); blob.pbData = encodedHashCN; blob.cbData = sizeof(encodedHashCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, hashCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleHashCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"#\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"#\""); blob.pbData = encodedSemiCN; blob.cbData = sizeof(encodedSemiCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, semiCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSemiCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\";\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\";\""); blob.pbData = encodedNewlineCN; blob.cbData = sizeof(encodedNewlineCN); - test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, newlineCN_W, FALSE); - test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleNewlineCN_W, - FALSE); + test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a\nb\""); + test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a\nb\""); } struct StrToNameA @@ -733,74 +783,68 @@ static void test_CertStrToNameA(void) DWORD size, i; BYTE buf[100]; - if (!pCertStrToNameA) - { - win_skip("CertStrToNameA is not available\n"); - return; - } - /* Crash - ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL); + ret = CertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL); */ - ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, NULL, 0, NULL, NULL, &size, NULL); ok(!ret, "Expected failure\n"); - ret = pCertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL); + ret = CertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL); + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL); + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL); - ok(ret, "CertStrToNameA failed: %08x\n", GetLastError()); + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL); + ok(ret, "CertStrToNameA failed: %08lx\n", GetLastError()); size = sizeof(buf); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"\"1\"\"", 0, NULL, buf, &size, + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=\"\"1\"\"", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf, + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf, + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected ERROR_SUCCESS, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"1,2;3,4\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=\"1,2;3,4\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf, + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected ERROR_SUCCESS, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected ERROR_SUCCESS, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", 0, NULL, buf, + "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", 0, NULL, buf, &size, NULL); ok(ret && GetLastError() == ERROR_SUCCESS, - "Expected ERROR_SUCCESS, got %08x\n", GetLastError()); - ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, + "Expected ERROR_SUCCESS, got %08lx\n", GetLastError()); + ret = CertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf, &size, NULL); ok(!ret && GetLastError() == ERROR_MORE_DATA, - "Expected ERROR_MORE_DATA, got %08x\n", GetLastError()); + "Expected ERROR_MORE_DATA, got %08lx\n", GetLastError()); for (i = 0; i < ARRAY_SIZE(namesA); i++) { size = sizeof(buf); - ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf, + ret = CertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf, &size, NULL); - ok(ret, "CertStrToNameA failed on string %s: %08x\n", namesA[i].x500, + ok(ret, "CertStrToNameA failed on string %s: %08lx\n", namesA[i].x500, GetLastError()); ok(size == namesA[i].encodedSize, - "Expected size %d, got %d\n", namesA[i].encodedSize, size); + "Expected size %ld, got %ld\n", namesA[i].encodedSize, size); if (ret) ok(!memcmp(buf, namesA[i].encoded, namesA[i].encodedSize), "Unexpected value for string %s\n", namesA[i].x500); @@ -814,266 +858,380 @@ struct StrToNameW const BYTE *encoded; }; -static const WCHAR badlyQuotedCN_W[] = { 'C','N','=','"','"','1','"','"',0 }; -static const WCHAR simpleCN2_W[] = { 'C','N','=','"','1','"',0 }; -static const WCHAR simpleCN3_W[] = { 'C','N',' ','=',' ','"','1','"',0 }; -static const WCHAR japaneseCN_W[] = { 'C','N','=',0x226f,0x575b,0 }; -static const WCHAR dummyCN_W[] = { 'C','N','=','d','u','m','m','y',',','T','=','t','e','s','t',0 }; -static const WCHAR encodedFields_W[] = { ' ','C','N',' ','=',' ',' ',' ','W','i','n','e',' ','T', - 'e','s','t',',','T',' ','=',' ','1','2','3',',',' ','C', - ' ','=',' ','B','R',0 }; static const BYTE encodedJapaneseCN[] = { 0x30,0x0f,0x31,0x0d,0x30,0x0b,0x06, 0x03,0x55,0x04,0x03,0x1e,0x04,0x22,0x6f,0x57,0x5b }; static const struct StrToNameW namesW[] = { - { simpleCN_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { simpleCN2_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { simpleCN3_W, sizeof(encodedSimpleCN), encodedSimpleCN }, - { singledQuotedCN_W, sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN }, - { spacedCN_W, sizeof(encodedSpacedCN), encodedSpacedCN }, - { quotedCN_W, sizeof(encodedQuotedCN), encodedQuotedCN }, - { multipleAttrCN_W, sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN }, - { japaneseCN_W, sizeof(encodedJapaneseCN), encodedJapaneseCN }, - { commaCN_W, sizeof(encodedCommaCN), encodedCommaCN }, - { equalCN_W, sizeof(encodedEqualCN), encodedEqualCN }, - { lessThanCN_W, sizeof(encodedLessThanCN), encodedLessThanCN }, - { greaterThanCN_W, sizeof(encodedGreaterThanCN), encodedGreaterThanCN }, - { hashCN_W, sizeof(encodedHashCN), encodedHashCN }, - { semiCN_W, sizeof(encodedSemiCN), encodedSemiCN }, - { dummyCN_W, sizeof(encodedDummyCN), encodedDummyCN }, - { encodedFields_W, sizeof(encodedFields), encodedFields }, + { L"CN=1", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN=\"1\"", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN = \"1\"", sizeof(encodedSimpleCN), encodedSimpleCN }, + { L"CN='1'", sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN }, + { L"CN=\" 1 \"", sizeof(encodedSpacedCN), encodedSpacedCN }, + { L"CN=\"\"\"1\"\"\"", sizeof(encodedQuotedCN), encodedQuotedCN }, + { L"CN=\"1+2\"", sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN }, + { L"CN=\x226f\x575b", sizeof(encodedJapaneseCN), encodedJapaneseCN }, + { L"CN=\"a,b\"", sizeof(encodedCommaCN), encodedCommaCN }, + { L"CN=\"a=b\"", sizeof(encodedEqualCN), encodedEqualCN }, + { L"CN=\"<\"", sizeof(encodedLessThanCN), encodedLessThanCN }, + { L"CN=\">\"", sizeof(encodedGreaterThanCN), encodedGreaterThanCN }, + { L"CN=\"#\"", sizeof(encodedHashCN), encodedHashCN }, + { L"CN=\";\"", sizeof(encodedSemiCN), encodedSemiCN }, + { L"CN=dummy,T=test", sizeof(encodedDummyCN), encodedDummyCN }, + { L" CN = Wine Test,T = 123, C = BR", sizeof(encodedFields), encodedFields }, }; static void test_CertStrToNameW(void) { - static const WCHAR bogusW[] = { 'b','o','g','u','s',0 }; - static const WCHAR fooW[] = { 'f','o','o','=','1',0 }; BOOL ret; DWORD size, i; LPCWSTR errorPtr; BYTE buf[100]; - if (!pCertStrToNameW) - { - win_skip("CertStrToNameW is not available\n"); - return; - } - /* Crash - ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL); + ret = CertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL); */ - ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL); ok(!ret, "Expected failure\n"); - ret = pCertStrToNameW(0, bogusW, 0, NULL, NULL, &size, NULL); + ret = CertStrToNameW(0, L"bogus", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameW(0, fooW, 0, NULL, NULL, &size, NULL); + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameW(0, L"foo=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameW(0, simpleCN_W, 0, NULL, NULL, &size, NULL); + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameW(0, L"CN=1", 0, NULL, NULL, &size, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = pCertStrToNameW(X509_ASN_ENCODING, simpleCN_W, 0, NULL, NULL, &size, + "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError()); + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=1", 0, NULL, NULL, &size, NULL); - ok(ret, "CertStrToNameW failed: %08x\n", GetLastError()); + ok(ret, "CertStrToNameW failed: %08lx\n", GetLastError()); size = sizeof(buf); - ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf, + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=\"\"1\"\"", 0, NULL, buf, &size, NULL); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); - ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf, + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); + ret = CertStrToNameW(X509_ASN_ENCODING, L"CN=\"\"1\"\"", 0, NULL, buf, &size, &errorPtr); ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, - "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); + "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError()); ok(errorPtr && *errorPtr == '1', "Expected first error character was 1\n"); for (i = 0; i < ARRAY_SIZE(namesW); i++) { size = sizeof(buf); - ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf, + ret = CertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf, &size, NULL); - ok(ret, "Index %d: CertStrToNameW failed: %08x\n", i, GetLastError()); + ok(ret, "Index %ld: CertStrToNameW failed: %08lx\n", i, GetLastError()); ok(size == namesW[i].encodedSize, - "Index %d: expected size %d, got %d\n", i, namesW[i].encodedSize, + "Index %ld: expected size %ld, got %ld\n", i, namesW[i].encodedSize, size); if (ret) ok(!memcmp(buf, namesW[i].encoded, size), - "Index %d: unexpected value for string %s\n", i, wine_dbgstr_w(namesW[i].x500)); + "Index %ld: unexpected value for string %s\n", i, wine_dbgstr_w(namesW[i].x500)); } } -static void test_CertGetNameStringA(void) +#define test_CertGetNameString_value(a, b, c, d, e) test_CertGetNameString_value_(__LINE__, a, b, c, d, e) +static void test_CertGetNameString_value_(unsigned int line, PCCERT_CONTEXT context, DWORD type, DWORD flags, + void *type_para, const char *expected) { - PCCERT_CONTEXT context; + DWORD len, retlen, expected_len; + WCHAR expectedW[512]; + WCHAR strW[512]; + char str[512]; - if (!pCertGetNameStringA) + expected_len = 0; + while(expected[expected_len]) { - win_skip("CertGetNameStringA is not available\n"); + while((expectedW[expected_len] = expected[expected_len])) + ++expected_len; + if (!(flags & CERT_NAME_SEARCH_ALL_NAMES_FLAG)) + break; + expectedW[expected_len++] = 0; + } + expectedW[expected_len++] = 0; + + len = CertGetNameStringA(context, type, flags, type_para, NULL, 0); + if (flags & CERT_NAME_SEARCH_ALL_NAMES_FLAG && ((type == CERT_NAME_DNS_TYPE && len < expected_len) + || (type != CERT_NAME_DNS_TYPE && len > expected_len))) + { + /* Supported since Win8. */ + win_skip("line %u: CERT_NAME_SEARCH_ALL_NAMES_FLAG is not supported.\n", line); return; } + ok(len == expected_len, "line %u: unexpected length %ld, expected %ld.\n", line, len, expected_len); + memset(str, 0xcc, len); + retlen = CertGetNameStringA(context, type, flags, type_para, str, len); + ok(retlen == len, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len); + ok(!memcmp(str, expected, expected_len), "line %u: unexpected value %s.\n", line, debugstr_an(str, expected_len)); + str[0] = str[1] = 0xcc; + retlen = CertGetNameStringA(context, type, flags, type_para, str, len - 1); + ok(retlen == 1, "line %u: Unexpected len %lu, expected 1.\n", line, retlen); + if (len == 1) return; + ok(!str[0], "line %u: unexpected str[0] %#x.\n", line, str[0]); + ok(str[1] == expected[1], "line %u: unexpected str[1] %#x.\n", line, str[1]); + ok(!memcmp(str + 1, expected + 1, len - 2), + "line %u: str %s, string data mismatch.\n", line, debugstr_a(str + 1)); + retlen = CertGetNameStringA(context, type, flags, type_para, str, 0); + ok(retlen == len, "line %u: Unexpected len %lu, expected 1.\n", line, retlen); + + memset(strW, 0xcc, len * sizeof(*strW)); + retlen = CertGetNameStringW(context, type, flags, type_para, strW, len); + ok(retlen == expected_len, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, expected_len); + ok(!memcmp(strW, expectedW, len * sizeof(*strW)), "line %u: unexpected value %s.\n", line, debugstr_wn(strW, len)); + strW[0] = strW[1] = 0xcccc; + retlen = CertGetNameStringW(context, type, flags, type_para, strW, len - 1); + ok(retlen == len - 1, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len - 1); + if (flags & CERT_NAME_SEARCH_ALL_NAMES_FLAG) + { + ok(!memcmp(strW, expectedW, (retlen - 2) * sizeof(*strW)), + "line %u: str %s, string data mismatch.\n", line, debugstr_wn(strW, retlen - 2)); + ok(!strW[retlen - 2], "line %u: string is not zero terminated.\n", line); + ok(!strW[retlen - 1], "line %u: string sequence is not zero terminated.\n", line); + + retlen = CertGetNameStringW(context, type, flags, type_para, strW, 1); + ok(retlen == 1, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len - 1); + ok(!strW[retlen - 1], "line %u: string sequence is not zero terminated.\n", line); + } + else + { + ok(!memcmp(strW, expectedW, (retlen - 1) * sizeof(*strW)), + "line %u: str %s, string data mismatch.\n", line, debugstr_wn(strW, retlen - 1)); + ok(!strW[retlen - 1], "line %u: string is not zero terminated.\n", line); + } + retlen = CertGetNameStringA(context, type, flags, type_para, NULL, len - 1); + ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len); + retlen = CertGetNameStringW(context, type, flags, type_para, NULL, len - 1); + ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len); +} + +static void test_CertGetNameString(void) +{ + static const char aric[] = "aric@codeweavers.com"; + static const char localhost[] = "localhost"; + PCCERT_CONTEXT context; + DWORD len, type; context = CertCreateCertificateContext(X509_ASN_ENCODING, cert, sizeof(cert)); - ok(context != NULL, "CertCreateCertificateContext failed: %08x\n", - GetLastError()); - if (context) + ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError()); + + /* Bad string types/types missing from the cert */ + len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + + len = CertGetNameStringW(NULL, 0, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + len = CertGetNameStringW(context, 0, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + len = CertGetNameStringW(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0); + ok(len == 1, "expected 1, got %lu\n", len); + + test_CertGetNameString_value(context, CERT_NAME_EMAIL_TYPE, 0, NULL, aric); + test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, 0, NULL, issuerStr); + type = 0; + test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, 0, &type, issuerStr); + type = CERT_OID_NAME_STR; + test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, 0, &type, subjectStr); + test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, 0, NULL, aric); + test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_RSA_emailAddr, aric); + test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_COMMON_NAME, localhost); + test_CertGetNameString_value(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, localhost); + test_CertGetNameString_value(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, localhost); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, 0, NULL, localhost); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, CERT_NAME_SEARCH_ALL_NAMES_FLAG, NULL, "localhost\0"); + test_CertGetNameString_value(context, CERT_NAME_EMAIL_TYPE, CERT_NAME_SEARCH_ALL_NAMES_FLAG, NULL, ""); + test_CertGetNameString_value(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_SEARCH_ALL_NAMES_FLAG, NULL, ""); + + CertFreeCertificateContext(context); + + context = CertCreateCertificateContext(X509_ASN_ENCODING, cert_no_email, + sizeof(cert_no_email)); + ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError()); + + test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, 0, NULL, localhost); + + CertFreeCertificateContext(context); + + ok(cert_v3[CERT_V3_SAN_OID_OFFSET] == 0x55, "Incorrect CERT_V3_SAN_OID_OFFSET.\n"); + ok(cert_v3[CERT_V3_IAN_OID_OFFSET] == 0x55, "Incorrect CERT_V3_IAN_OID_OFFSET.\n"); + cert_v3[CERT_V3_SAN_OID_OFFSET + 2] = 7; /* legacy OID_SUBJECT_ALT_NAME */ + cert_v3[CERT_V3_IAN_OID_OFFSET + 2] = 8; /* legacy OID_ISSUER_ALT_NAME */ + context = CertCreateCertificateContext(X509_ASN_ENCODING, cert_v3, sizeof(cert_v3)); + ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError()); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, 0, NULL, "ex1.org"); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, CERT_NAME_ISSUER_FLAG, NULL, "ex3.org"); + CertFreeCertificateContext(context); + + cert_v3[CERT_V3_SAN_OID_OFFSET + 2] = 17; /* OID_SUBJECT_ALT_NAME2 */ + cert_v3[CERT_V3_IAN_OID_OFFSET + 2] = 18; /* OID_ISSUER_ALT_NAME2 */ + context = CertCreateCertificateContext(X509_ASN_ENCODING, cert_v3, sizeof(cert_v3)); + ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError()); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, 0, NULL, "ex1.org"); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, CERT_NAME_ISSUER_FLAG, NULL, "ex3.org"); + test_CertGetNameString_value(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, "server_cn.org"); + test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, 0, (void *)szOID_SUR_NAME, ""); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, CERT_NAME_SEARCH_ALL_NAMES_FLAG, + NULL, "ex1.org\0*.ex2.org\0"); + test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, CERT_NAME_SEARCH_ALL_NAMES_FLAG | CERT_NAME_ISSUER_FLAG, + NULL, "ex3.org\0*.ex4.org\0"); + CertFreeCertificateContext(context); +} + +static void test_quoted_RDN(void) +{ + static const WCHAR str1[] = { '1',0x00a0,0 }; + static const WCHAR str2[] = { '1',0x3000,0 }; + static const struct { - static const char aric[] = "aric@codeweavers.com"; - static const char localhost[] = "localhost"; - DWORD len, type; - LPSTR str; + const WCHAR *CN; + const WCHAR *X500_CN; + } test[] = + { + { L"1", L"1" }, + { L" 1", L"\" 1\"" }, + { L"1 ", L"\"1 \"" }, + { L"\"1\"", L"\"\"\"1\"\"\"" }, + { L"\" 1 \"", L"\"\"\" 1 \"\"\"" }, + { L"\"\"\"1\"\"\"", L"\"\"\"\"\"\"\"1\"\"\"\"\"\"\"" }, + { L"1+", L"\"1+\"" }, + { L"1=", L"\"1=\"" }, + { L"1\"", L"\"1\"\"\"" }, + { L"1<", L"\"1<\"" }, + { L"1>", L"\"1>\"" }, + { L"1#", L"\"1#\"" }, + { L"1+", L"\"1+\"" }, + { L"1\t", L"\"1\t\"" }, + { L"1\r", L"\"1\r\"" }, + { L"1\n", L"\"1\n\"" }, + { str1, str1 }, + { str2, str2 }, + }; + CERT_RDN_ATTR attr; + CERT_RDN rdn; + CERT_NAME_INFO info; + CERT_NAME_BLOB blob; + BYTE *buf; + WCHAR str[256]; + DWORD size, ret, i; - /* Bad string types/types missing from the cert */ - len = pCertGetNameStringA(NULL, 0, 0, NULL, NULL, 0); - ok(len == 1, "expected 1, got %d\n", len); - len = pCertGetNameStringA(context, 0, 0, NULL, NULL, 0); - ok(len == 1, "expected 1, got %d\n", len); - len = pCertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, - 0); - ok(len == 1, "expected 1, got %d\n", len); + for (i = 0; i < ARRAY_SIZE(test); i++) + { + winetest_push_context("%lu", i); - len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL, - 0); - ok(len == strlen(aric) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, - str, len); - ok(!strcmp(str, aric), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } + attr.pszObjId = (LPSTR)szOID_COMMON_NAME; + attr.dwValueType = CERT_RDN_UNICODE_STRING; + attr.Value.cbData = wcslen(test[i].CN) * sizeof(WCHAR); + attr.Value.pbData = (BYTE *)test[i].CN; + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = &attr; + info.cRDN = 1; + info.rgRDN = &rdn; + buf = NULL; + size = 0; + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "CryptEncodeObjectEx error %08lx\n", GetLastError()); - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL, - 0); - ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, - str, len); - ok(!strcmp(str, issuerStr), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } - type = 0; - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, - 0); - ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, - str, len); - ok(!strcmp(str, issuerStr), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } - type = CERT_OID_NAME_STR; - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL, - 0); - ok(len == strlen(subjectStr) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, - str, len); - ok(!strcmp(str, subjectStr), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } + blob.pbData = buf; + blob.cbData = size; - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL, - 0); - ok(len == strlen(aric) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, - str, len); - ok(!strcmp(str, aric), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, - (void *)szOID_RSA_emailAddr, NULL, 0); - ok(len == strlen(aric) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, - (void *)szOID_RSA_emailAddr, str, len); - ok(!strcmp(str, aric), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, - (void *)szOID_COMMON_NAME, NULL, 0); - ok(len == strlen(localhost) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, - (void *)szOID_COMMON_NAME, str, len); - ok(!strcmp(str, localhost), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, 0, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcscmp(str, test[i].X500_CN), "got %s, expected %s\n", debugstr_w(str), debugstr_w(test[i].X500_CN)); - len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, - NULL, NULL, 0); - ok(len == strlen(localhost) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, - 0, NULL, str, len); - ok(!strcmp(str, localhost), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_SIMPLE_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcscmp(str, test[i].X500_CN), "got %s, expected %s\n", debugstr_w(str), debugstr_w(test[i].X500_CN)); - len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, - NULL, NULL, 0); - ok(len == strlen(localhost) + 1, "unexpected length %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, - 0, NULL, str, len); - ok(!strcmp(str, localhost), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_OID_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"2.5.4.3=", 8), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[8], test[i].X500_CN), "got %s, expected %s\n", debugstr_w(&str[8]), debugstr_w(test[i].X500_CN)); - len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL, - 0); - ok(len == strlen(localhost) + 1 || broken(len == 1) /* NT4 */, - "unexpected length %d\n", len); - if (len > 1) - { - str = HeapAlloc(GetProcessHeap(), 0, len); - if (str) - { - len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, - str, len); - ok(!strcmp(str, localhost), "unexpected value %s\n", str); - HeapFree(GetProcessHeap(), 0, str); - } - } + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_X500_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"CN=", 3), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[3], test[i].X500_CN), "got %s, expected %s\n", debugstr_w(&str[3]), debugstr_w(test[i].X500_CN)); - CertFreeCertificateContext(context); + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_X500_NAME_STR | CERT_NAME_STR_NO_QUOTING_FLAG, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"CN=", 3), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[3], test[i].CN), "got %s, expected %s\n", debugstr_w(&str[3]), debugstr_w(test[i].CN)); + + LocalFree(buf); + + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test); i++) + { + winetest_push_context("%lu", i); + + attr.pszObjId = (LPSTR)szOID_COMMON_NAME; + attr.dwValueType = CERT_RDN_UTF8_STRING; + attr.Value.cbData = wcslen(test[i].CN) * sizeof(WCHAR); + attr.Value.pbData = (BYTE *)test[i].CN; + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = &attr; + info.cRDN = 1; + info.rgRDN = &rdn; + buf = NULL; + size = 0; + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "CryptEncodeObjectEx error %08lx\n", GetLastError()); + + blob.pbData = buf; + blob.cbData = size; + + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, 0, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcscmp(str, test[i].X500_CN), "got %s, expected %s\n", debugstr_w(str), debugstr_w(test[i].X500_CN)); + + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_SIMPLE_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcscmp(str, test[i].X500_CN), "got %s, expected %s\n", debugstr_w(str), debugstr_w(test[i].X500_CN)); + + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_OID_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"2.5.4.3=", 8), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[8], test[i].X500_CN), "got %s, expected %s\n", debugstr_w(&str[8]), debugstr_w(test[i].X500_CN)); + + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_X500_NAME_STR, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"CN=", 3), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[3], test[i].X500_CN), "got %s, expected %s\n", debugstr_w(&str[3]), debugstr_w(test[i].X500_CN)); + + str[0] = 0; + ret = CertNameToStrW(X509_ASN_ENCODING, &blob, CERT_X500_NAME_STR | CERT_NAME_STR_NO_QUOTING_FLAG, str, ARRAY_SIZE(str)); + ok(ret, "CertNameToStr error %08lx\n", GetLastError()); + ok(!wcsncmp(str, L"CN=", 3), "got %s\n", debugstr_w(str)); + ok(!wcscmp(&str[3], test[i].CN), "got %s, expected %s\n", debugstr_w(&str[3]), debugstr_w(test[i].CN)); + + LocalFree(buf); + + winetest_pop_context(); } } START_TEST(str) { - dll = GetModuleHandleA("Crypt32.dll"); - - pCertNameToStrA = (void*)GetProcAddress(dll,"CertNameToStrA"); - pCertNameToStrW = (void*)GetProcAddress(dll,"CertNameToStrW"); - pCertRDNValueToStrA = (void*)GetProcAddress(dll, "CertRDNValueToStrA"); - pCertRDNValueToStrW = (void*)GetProcAddress(dll, "CertRDNValueToStrW"); - pCertStrToNameA = (void*)GetProcAddress(dll,"CertStrToNameA"); - pCertStrToNameW = (void*)GetProcAddress(dll,"CertStrToNameW"); - pCertGetNameStringA = (void*)GetProcAddress(dll, "CertGetNameStringA"); - + test_quoted_RDN(); test_CertRDNValueToStrA(); test_CertRDNValueToStrW(); test_CertNameToStrA(); test_CertNameToStrW(); test_CertStrToNameA(); test_CertStrToNameW(); - test_CertGetNameStringA(); + test_CertGetNameString(); }