https://git.reactos.org/?p=reactos.git;a=commitdiff;h=06fdb3e6abc71aa668718…
commit 06fdb3e6abc71aa66871851b25ef03741ee9dd22
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Mon Oct 1 12:48:33 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Mon Oct 1 12:48:33 2018 +0100
[CRYPT32_WINETEST] Sync with Wine Staging 3.17. CORE-15127
---
modules/rostests/winetests/crypt32/base64.c | 350 +++++++++++++++------
modules/rostests/winetests/crypt32/cert.c | 2 +-
modules/rostests/winetests/crypt32/chain.c | 451 ++++++++++++----------------
modules/rostests/winetests/crypt32/encode.c | 276 ++++-------------
modules/rostests/winetests/crypt32/main.c | 8 +-
modules/rostests/winetests/crypt32/msg.c | 6 +-
modules/rostests/winetests/crypt32/oid.c | 101 +++----
modules/rostests/winetests/crypt32/sip.c | 9 +-
modules/rostests/winetests/crypt32/store.c | 6 +-
modules/rostests/winetests/crypt32/str.c | 17 +-
10 files changed, 557 insertions(+), 669 deletions(-)
diff --git a/modules/rostests/winetests/crypt32/base64.c
b/modules/rostests/winetests/crypt32/base64.c
index e127fc3891..4ff76272e3 100644
--- a/modules/rostests/winetests/crypt32/base64.c
+++ b/modules/rostests/winetests/crypt32/base64.c
@@ -20,11 +20,10 @@
*/
#include <stdio.h>
#include <stdarg.h>
-#include <windef.h>
-#include <winbase.h>
-#include <winerror.h>
+#include <windows.h>
#include <wincrypt.h>
+#include "wine/heap.h"
#include "wine/test.h"
#define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n"
@@ -56,6 +55,8 @@ static const BYTE toEncode4[] =
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
+static const BYTE toEncode5[] =
+ "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI";
static const struct BinTests tests[] = {
{ toEncode1, sizeof(toEncode1), "AA==\r\n", },
@@ -67,6 +68,8 @@ static const struct BinTests tests[] = {
"d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\r\n"
"Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\r\n"
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" },
+ { toEncode5, sizeof(toEncode5),
+ "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\r\n" },
};
static const struct BinTests testsNoCR[] = {
@@ -79,131 +82,284 @@ static const struct BinTests testsNoCR[] = {
"d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\n"
"Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\n"
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" },
+ { toEncode5, sizeof(toEncode5),
+ "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\n" },
};
+static WCHAR *strdupAtoW(const char *str)
+{
+ WCHAR *ret = NULL;
+ DWORD len;
+
+ if (!str) return ret;
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ ret = heap_alloc(len * sizeof(WCHAR));
+ if (ret)
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+ return ret;
+}
+
static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
DWORD format, const char *expected, const char *header, const char *trailer)
{
- DWORD strLen = 0;
+ DWORD strLen, strLen2, required;
+ const char *ptr;
LPSTR str = NULL;
BOOL ret;
+ required = strlen(expected) + 1;
+ if (header)
+ required += strlen(header);
+ if (trailer)
+ required += strlen(trailer);
+
+ strLen = 0;
ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
- str = HeapAlloc(GetProcessHeap(), 0, strLen);
- if (str)
+ ok(strLen == required, "Unexpected required length %u, expected %u.\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");
+
+ strLen2 = strLen - 1;
+ ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2);
+ ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
+ ok(strLen == strLen2, "Unexpected required length.\n");
+
+ str = heap_alloc(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",
+ ret, GetLastError());
+ ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got
%d\n", strLen - 1, strLen);
+todo_wine {
+ 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);
+
+ ptr = str;
+ if (header)
{
- DWORD strLen2 = strLen;
- LPCSTR ptr = str;
+ ok(!strncmp(header, ptr, strlen(header)), "Expected header %s, got
%s\n", header, ptr);
+ ptr += strlen(header);
+ }
+ ok(!strncmp(expected, ptr, strlen(expected)), "Expected %s, got %s\n",
expected, ptr);
+ ptr += strlen(expected);
+ if (trailer)
+ ok(!strncmp(trailer, ptr, strlen(trailer)), "Expected trailer %s, got
%s\n", trailer, ptr);
- 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);
- if (header)
- {
- ok(!strncmp(header, ptr, strlen(header)),
- "Expected header %s, got %s\n", header, ptr);
- ptr += strlen(header);
- }
- ok(!strncmp(expected, ptr, strlen(expected)),
- "Expected %s, got %s\n", expected, ptr);
- ptr += strlen(expected);
- if (trailer)
- ok(!strncmp(trailer, ptr, strlen(trailer)),
- "Expected trailer %s, got %s\n", trailer, ptr);
- HeapFree(GetProcessHeap(), 0, str);
+ heap_free(str);
+}
+
+static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWORD
format,
+ const WCHAR *expected, const char *header, const char *trailer)
+{
+ WCHAR *headerW, *trailerW, required;
+ DWORD strLen, strLen2;
+ WCHAR *strW = NULL;
+ const WCHAR *ptr;
+ BOOL ret;
+
+ required = lstrlenW(expected) + 1;
+ if (header)
+ required += strlen(header);
+ if (trailer)
+ required += strlen(trailer);
+
+ 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);
+
+ /* Same call with non-zero length value. */
+ strLen2 = strLen;
+ ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2);
+ ok(ret, "CryptBinaryToStringW failed: %d\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(strLen == strLen2, "Unexpected required length.\n");
+
+ strLen2 = strLen - 1;
+ ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2);
+ ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+ ok(strLen == strLen2, "Unexpected required length.\n");
+
+ strW = heap_alloc(strLen * sizeof(WCHAR));
+
+ headerW = strdupAtoW(header);
+ trailerW = strdupAtoW(trailer);
+
+ 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",
+ ret, GetLastError());
+ if (headerW)
+ ok(strW[0] == 0x1234, "Unexpected buffer contents %#x.\n", strW[0]);
+ else
+ ok(strW[0] == 0x1234 || broken(strW[0] != 0x1234) /* XP */, "Unexpected
buffer contents %#x.\n", strW[0]);
+
+ strLen2 = strLen;
+ ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2);
+ ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+
+ ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1,
strLen);
+
+ ptr = strW;
+ if (headerW)
+ {
+ ok(!memcmp(headerW, ptr, lstrlenW(headerW)), "Expected header %s, got
%s.\n", wine_dbgstr_w(headerW),
+ wine_dbgstr_w(ptr));
+ ptr += lstrlenW(headerW);
}
+ ok(!memcmp(expected, ptr, lstrlenW(expected)), "Expected %s, got %s.\n",
wine_dbgstr_w(expected),
+ wine_dbgstr_w(ptr));
+ ptr += lstrlenW(expected);
+ if (trailerW)
+ 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);
}
-static void testBinaryToStringA(void)
+static void test_CryptBinaryToString(void)
{
+ DWORD strLen, strLen2, i;
BOOL ret;
- DWORD strLen = 0, i;
ret = CryptBinaryToStringA(NULL, 0, 0, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\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());
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ ok(strLen == 123, "Unexpected length.\n");
+
+ if (0)
+ ret = CryptBinaryToStringW(NULL, 0, 0, NULL, NULL);
+
+ strLen = 123;
+ ret = CryptBinaryToStringW(NULL, 0, 0, NULL, &strLen);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error
%d\n", GetLastError());
+ ok(strLen == 123, "Unexpected length.\n");
+
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
- DWORD strLen = 0;
+ WCHAR *strW, *encodedW;
LPSTR str = NULL;
BOOL ret;
- ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
- CRYPT_STRING_BINARY, NULL, &strLen);
+ strLen = 0;
+ ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BINARY, NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
- str = HeapAlloc(GetProcessHeap(), 0, strLen);
- if (str)
- {
- DWORD strLen2 = 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 %d, got %d\n", strLen,
- strLen2);
- ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen),
- "Unexpected value\n");
- HeapFree(GetProcessHeap(), 0, str);
- }
- encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
- CRYPT_STRING_BASE64, tests[i].base64, NULL, NULL);
- encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
- CRYPT_STRING_BASE64HEADER, tests[i].base64, CERT_HEADER,
- CERT_TRAILER);
- encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
- CRYPT_STRING_BASE64REQUESTHEADER, tests[i].base64,
- CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER);
- encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
- CRYPT_STRING_BASE64X509CRLHEADER, tests[i].base64, X509_HEADER,
- X509_TRAILER);
+ ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n",
strLen);
+
+ strLen2 = strLen;
+ str = heap_alloc(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(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected
value\n");
+ heap_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);
+
+ strLen2 = strLen;
+ strW = heap_alloc(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(!memcmp(strW, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected
value\n");
+ heap_free(strW);
+
+ encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64,
+ tests[i].base64, NULL, NULL);
+ encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64HEADER,
+ tests[i].base64, CERT_HEADER, CERT_TRAILER);
+ encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64REQUESTHEADER,
+ tests[i].base64, CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER);
+ encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64X509CRLHEADER,
+ tests[i].base64, X509_HEADER, X509_TRAILER);
+
+ encodedW = strdupAtoW(tests[i].base64);
+
+ encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64, encodedW, NULL, NULL);
+ encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64HEADER, encodedW,
+ CERT_HEADER, CERT_TRAILER);
+ encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64REQUESTHEADER,
+ encodedW, CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER);
+ encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BASE64X509CRLHEADER, encodedW,
+ X509_HEADER, X509_TRAILER);
+
+ heap_free(encodedW);
}
- for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
+
+ for (i = 0; i < ARRAY_SIZE(testsNoCR); i++)
{
- DWORD strLen = 0;
LPSTR str = NULL;
+ WCHAR *encodedW;
BOOL ret;
- ret = CryptBinaryToStringA(testsNoCR[i].toEncode,
- testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR,
- NULL, &strLen);
+ ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
- str = HeapAlloc(GetProcessHeap(), 0, strLen);
- if (str)
- {
- DWORD strLen2 = 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(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen),
- "Unexpected value\n");
- HeapFree(GetProcessHeap(), 0, str);
- }
- encodeAndCompareBase64_A(testsNoCR[i].toEncode,
- testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR,
- testsNoCR[i].base64, NULL, NULL);
- encodeAndCompareBase64_A(testsNoCR[i].toEncode,
- testsNoCR[i].toEncodeLen,
- CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64,
- CERT_HEADER_NOCR, CERT_TRAILER_NOCR);
- encodeAndCompareBase64_A(testsNoCR[i].toEncode,
- testsNoCR[i].toEncodeLen,
- CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR,
- testsNoCR[i].base64, CERT_REQUEST_HEADER_NOCR,
- CERT_REQUEST_TRAILER_NOCR);
- encodeAndCompareBase64_A(testsNoCR[i].toEncode,
- testsNoCR[i].toEncodeLen,
- CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR,
- testsNoCR[i].base64, X509_HEADER_NOCR, X509_TRAILER_NOCR);
+
+ strLen2 = strLen;
+ str = heap_alloc(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(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen),
"Unexpected value\n");
+ heap_free(str);
+
+ encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR,
+ testsNoCR[i].base64, NULL, NULL);
+ encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64,
CERT_HEADER_NOCR, CERT_TRAILER_NOCR);
+ encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64,
CERT_REQUEST_HEADER_NOCR,
+ CERT_REQUEST_TRAILER_NOCR);
+ encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64,
X509_HEADER_NOCR, X509_TRAILER_NOCR);
+
+ encodedW = strdupAtoW(testsNoCR[i].base64);
+
+ encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, encodedW, NULL, NULL);
+ encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, encodedW, CERT_HEADER_NOCR,
CERT_TRAILER_NOCR);
+ encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR, encodedW,
CERT_REQUEST_HEADER_NOCR,
+ CERT_REQUEST_TRAILER_NOCR);
+ encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
+ CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, encodedW,
+ X509_HEADER_NOCR, X509_TRAILER_NOCR);
+
+ heap_free(encodedW);
}
}
@@ -380,7 +536,7 @@ static void testStringToBinaryA(void)
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError());
/* Bad strings */
- for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(badStrings); i++)
{
bufLen = 0;
ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format,
@@ -447,7 +603,7 @@ static void testStringToBinaryA(void)
ret, bufLen, buf[0]);
/* Good strings */
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
bufLen = 0;
/* Bogus length--oddly enough, that succeeds, even though it's not
@@ -504,7 +660,7 @@ static void testStringToBinaryA(void)
*/
}
/* And again, with no CR--decoding handles this automatically */
- for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(testsNoCR); i++)
{
bufLen = 0;
/* Bogus length--oddly enough, that succeeds, even though it's not
@@ -545,6 +701,6 @@ static void testStringToBinaryA(void)
START_TEST(base64)
{
- testBinaryToStringA();
+ test_CryptBinaryToString();
testStringToBinaryA();
}
diff --git a/modules/rostests/winetests/crypt32/cert.c
b/modules/rostests/winetests/crypt32/cert.c
index e49b2a9798..bb0cc525e7 100644
--- a/modules/rostests/winetests/crypt32/cert.c
+++ b/modules/rostests/winetests/crypt32/cert.c
@@ -3177,7 +3177,7 @@ static void testCompareIntegerBlob(void)
DWORD i;
BOOL ret;
- for (i = 0; i < sizeof(intBlobs) / sizeof(intBlobs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(intBlobs); i++)
{
ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2);
ok(ret == intBlobs[i].areEqual,
diff --git a/modules/rostests/winetests/crypt32/chain.c
b/modules/rostests/winetests/crypt32/chain.c
index e3b280b088..e2a7633526 100644
--- a/modules/rostests/winetests/crypt32/chain.c
+++ b/modules/rostests/winetests/crypt32/chain.c
@@ -2889,59 +2889,6 @@ 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 };
-static const BYTE ecc_crt[] = {
-0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b,0x26,0x86,0x0a,
-0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,
-0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,
-0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65,
-0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65,
-0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32,0x37,0x31,0x33,0x34,0x31,0x30,
-0x34,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30,
-0x34,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
-0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x54,0x65,
-0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x54,0x65,
-0x73,0x74,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,0xed,
-0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73,
-0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20,
-0xc1,0xeb,0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9,
-0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15,
-0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,
-0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85,
-0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48,
-0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94,
-0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29,
-0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee };
-static const BYTE ecc_ca[] = {
-0x30,0x82,0x01,0x9f,0x30,0x82,0x01,0x46,0xa0,0x03,0x02,0x01,0x02,0x02,0x09,
-0x00,0xf1,0x54,0xae,0x21,0x2e,0x4d,0x31,0x9f,0x30,0x0a,0x06,0x08,0x2a,0x86,
-0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,
-0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,
-0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,
-0x0c,0x04,0x57,0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32,
-0x37,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32,
-0x35,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,
-0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,
-0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,
-0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65,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,0x3b,0x3c,0x34,0xc8,0x3f,0x15,0xea,0x02,0x68,0x46,
-0x69,0xdf,0x0c,0xa6,0xee,0x7a,0xd9,0x82,0x08,0x9b,0x37,0x53,0x42,0xf3,0x13,
-0x63,0xda,0x65,0x79,0xe8,0x04,0x9e,0x8c,0x77,0xc4,0x33,0x77,0xd9,0x5a,0x7f,
-0x60,0x7b,0x98,0xce,0xf3,0x96,0x56,0xd6,0xb5,0x8d,0x87,0x7a,0x00,0x2b,0xf3,
-0x70,0xb3,0x90,0x73,0xa0,0x56,0x06,0x3b,0x22,0xa3,0x53,0x30,0x51,0x30,0x1d,
-0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x26,0xef,0x6f,0xe4,0xb5,0x24,
-0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5,0xe5,0x0c,0x30,
-0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x26,0xef,0x6f,
-0xe4,0xb5,0x24,0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5,
-0xe5,0x0c,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,0x47,0x00,0x30,0x44,0x02,0x20,0x2b,0x6b,0x23,0x42,0x32,0xf2,0xcb,
-0x71,0xd7,0x5c,0xfa,0x5e,0x6c,0x19,0x31,0xd6,0x74,0xf7,0xc0,0xf8,0xc6,0x39,
-0x38,0xe9,0x79,0x4d,0x84,0x44,0x40,0x13,0x8e,0x43,0x02,0x20,0x34,0xc7,0x61,
-0xbb,0x18,0x1c,0x85,0x34,0xe3,0x4c,0x30,0x28,0x42,0x0e,0x06,0x65,0x68,0x1d,
-0x76,0x53,0x24,0xa0,0x27,0xa5,0x84,0x3b,0x2d,0xf3,0xec,0x27,0x60,0xb2 };
-
typedef struct _CONST_DATA_BLOB
{
@@ -3139,8 +3086,6 @@ 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 };
-/* Wednesday, Nov 17, 2017 */
-static SYSTEMTIME nov2017 = { 2017, 11, 3, 17, 0, 0, 0, 0 };
typedef struct _ChainCheck
{
@@ -3160,7 +3105,7 @@ static const CERT_TRUST_STATUS elementStatus0[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus0[] = {
- { sizeof(elementStatus0) / sizeof(elementStatus0[0]), elementStatus0 },
+ { ARRAY_SIZE(elementStatus0), elementStatus0 },
};
static CONST_DATA_BLOB chain1[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3173,7 +3118,7 @@ static const CERT_TRUST_STATUS elementStatus1[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus1[] = {
- { sizeof(elementStatus1) / sizeof(elementStatus1[0]), elementStatus1 },
+ { ARRAY_SIZE(elementStatus1), elementStatus1 },
};
static CONST_DATA_BLOB chain2[] = {
{ sizeof(chain2_0), chain2_0 },
@@ -3185,7 +3130,7 @@ static const CERT_TRUST_STATUS elementStatus2[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus2[] = {
- { sizeof(elementStatus2) / sizeof(elementStatus2[0]), elementStatus2 },
+ { ARRAY_SIZE(elementStatus2), elementStatus2 },
};
static CONST_DATA_BLOB chain3[] = {
{ sizeof(chain3_0), chain3_0 },
@@ -3197,7 +3142,7 @@ static const CERT_TRUST_STATUS elementStatus3[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus3[] = {
- { sizeof(elementStatus3) / sizeof(elementStatus3[0]), elementStatus3 },
+ { ARRAY_SIZE(elementStatus3), elementStatus3 },
};
static CONST_DATA_BLOB chain4[] = {
{ sizeof(chain4_0), chain4_0 },
@@ -3211,7 +3156,7 @@ static const CERT_TRUST_STATUS elementStatus4[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus4[] = {
- { sizeof(elementStatus4) / sizeof(elementStatus4[0]), elementStatus4 },
+ { ARRAY_SIZE(elementStatus4), elementStatus4 },
};
static CONST_DATA_BLOB chain5[] = {
{ sizeof(chain5_0), chain5_0 },
@@ -3224,7 +3169,7 @@ static const CERT_TRUST_STATUS elementStatus5[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus5[] = {
- { sizeof(elementStatus5) / sizeof(elementStatus5[0]), elementStatus5 },
+ { ARRAY_SIZE(elementStatus5), elementStatus5 },
};
static CONST_DATA_BLOB chain6[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3236,7 +3181,7 @@ static const CERT_TRUST_STATUS elementStatus6[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus6[] = {
- { sizeof(elementStatus6) / sizeof(elementStatus6[0]), elementStatus6 },
+ { ARRAY_SIZE(elementStatus6), elementStatus6 },
};
static CONST_DATA_BLOB chain7[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3248,7 +3193,7 @@ static const CERT_TRUST_STATUS elementStatus7[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus7[] = {
- { sizeof(elementStatus7) / sizeof(elementStatus7[0]), elementStatus7 },
+ { ARRAY_SIZE(elementStatus7), elementStatus7 },
};
static CONST_DATA_BLOB chain8[] = {
{ sizeof(chain8_0), chain8_0 },
@@ -3262,7 +3207,7 @@ static const CERT_TRUST_STATUS elementStatus8[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck simpleStatus8[] = {
- { sizeof(elementStatus8) / sizeof(elementStatus8[0]), elementStatus8 },
+ { ARRAY_SIZE(elementStatus8), elementStatus8 },
};
static CONST_DATA_BLOB chain9[] = {
{ sizeof(chain9_0), chain9_0 },
@@ -3275,7 +3220,7 @@ static const CERT_TRUST_STATUS elementStatus9[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus9[] = {
- { sizeof(elementStatus9) / sizeof(elementStatus9[0]), elementStatus9 },
+ { ARRAY_SIZE(elementStatus9), elementStatus9 },
};
static CONST_DATA_BLOB chain10[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3288,7 +3233,7 @@ static const CERT_TRUST_STATUS elementStatus10[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus10[] = {
- { sizeof(elementStatus10) / sizeof(elementStatus10[0]), elementStatus10 },
+ { ARRAY_SIZE(elementStatus10), elementStatus10 },
};
static CONST_DATA_BLOB chain11[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3305,7 +3250,7 @@ static const CERT_TRUST_STATUS elementStatus12[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus12[] = {
- { sizeof(elementStatus12) / sizeof(elementStatus12[0]), elementStatus12 },
+ { ARRAY_SIZE(elementStatus12), elementStatus12 },
};
static CONST_DATA_BLOB chain13[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3317,7 +3262,7 @@ static const CERT_TRUST_STATUS elementStatus13[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus13[] = {
- { sizeof(elementStatus13) / sizeof(elementStatus13[0]), elementStatus13 },
+ { ARRAY_SIZE(elementStatus13), elementStatus13 },
};
static CONST_DATA_BLOB chain14[] = {
{ sizeof(chain14_0), chain14_0 },
@@ -3329,7 +3274,7 @@ static const CERT_TRUST_STATUS elementStatus14[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus14[] = {
- { sizeof(elementStatus14) / sizeof(elementStatus14[0]), elementStatus14 },
+ { ARRAY_SIZE(elementStatus14), elementStatus14 },
};
static CONST_DATA_BLOB chain15[] = {
{ sizeof(chain15_0), chain15_0 },
@@ -3341,7 +3286,7 @@ static const CERT_TRUST_STATUS elementStatus15[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus15[] = {
- { sizeof(elementStatus15) / sizeof(elementStatus15[0]), elementStatus15 },
+ { ARRAY_SIZE(elementStatus15), elementStatus15 },
};
static CONST_DATA_BLOB chain16[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3354,7 +3299,7 @@ static const CERT_TRUST_STATUS elementStatus16[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus16[] = {
- { sizeof(elementStatus16) / sizeof(elementStatus16[0]), elementStatus16 },
+ { ARRAY_SIZE(elementStatus16), elementStatus16 },
};
static CONST_DATA_BLOB chain17[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3368,7 +3313,7 @@ static const CERT_TRUST_STATUS elementStatus17[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus17[] = {
- { sizeof(elementStatus17) / sizeof(elementStatus17[0]), elementStatus17 },
+ { ARRAY_SIZE(elementStatus17), elementStatus17 },
};
static CONST_DATA_BLOB chain18[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3382,7 +3327,7 @@ static const CERT_TRUST_STATUS elementStatus18[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus18[] = {
- { sizeof(elementStatus18) / sizeof(elementStatus18[0]), elementStatus18 },
+ { ARRAY_SIZE(elementStatus18), elementStatus18 },
};
static CONST_DATA_BLOB chain19[] = {
{ sizeof(chain19_0), chain19_0 },
@@ -3395,7 +3340,7 @@ static const CERT_TRUST_STATUS elementStatus19[] = {
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS },
};
static const SimpleChainStatusCheck simpleStatus19[] = {
- { sizeof(elementStatus19) / sizeof(elementStatus19[0]), elementStatus19 },
+ { ARRAY_SIZE(elementStatus19), elementStatus19 },
};
static CONST_DATA_BLOB chain20[] = {
{ sizeof(chain20_0), chain20_0 },
@@ -3407,7 +3352,7 @@ static const CERT_TRUST_STATUS elementStatus20[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus20[] = {
- { sizeof(elementStatus20) / sizeof(elementStatus20[0]), elementStatus20 },
+ { ARRAY_SIZE(elementStatus20), elementStatus20 },
};
static CONST_DATA_BLOB chain21[] = {
{ sizeof(chain21_0), chain21_0 },
@@ -3420,7 +3365,7 @@ static const CERT_TRUST_STATUS elementStatus21[] = {
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS },
};
static const SimpleChainStatusCheck simpleStatus21[] = {
- { sizeof(elementStatus21) / sizeof(elementStatus21[0]), elementStatus21 },
+ { ARRAY_SIZE(elementStatus21), elementStatus21 },
};
static CONST_DATA_BLOB chain22[] = {
{ sizeof(chain22_0), chain22_0 },
@@ -3432,7 +3377,7 @@ static const CERT_TRUST_STATUS elementStatus22[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus22[] = {
- { sizeof(elementStatus22) / sizeof(elementStatus22[0]), elementStatus22 },
+ { ARRAY_SIZE(elementStatus22), elementStatus22 },
};
static CONST_DATA_BLOB chain23[] = {
{ sizeof(chain23_0), chain23_0 },
@@ -3444,7 +3389,7 @@ static const CERT_TRUST_STATUS elementStatus23[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus23[] = {
- { sizeof(elementStatus23) / sizeof(elementStatus23[0]), elementStatus23 },
+ { ARRAY_SIZE(elementStatus23), elementStatus23 },
};
static CONST_DATA_BLOB chain24[] = {
{ sizeof(chain24_0), chain24_0 },
@@ -3456,7 +3401,7 @@ static const CERT_TRUST_STATUS elementStatus24[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus24[] = {
- { sizeof(elementStatus24) / sizeof(elementStatus24[0]), elementStatus24 },
+ { ARRAY_SIZE(elementStatus24), elementStatus24 },
};
static CONST_DATA_BLOB chain25[] = {
{ sizeof(chain25_0), chain25_0 },
@@ -3468,7 +3413,7 @@ static const CERT_TRUST_STATUS elementStatus25[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus25[] = {
- { sizeof(elementStatus25) / sizeof(elementStatus25[0]), elementStatus25 },
+ { ARRAY_SIZE(elementStatus25), elementStatus25 },
};
static CONST_DATA_BLOB chain26[] = {
{ sizeof(chain26_0), chain26_0 },
@@ -3480,7 +3425,7 @@ static const CERT_TRUST_STATUS elementStatus26[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus26[] = {
- { sizeof(elementStatus26) / sizeof(elementStatus26[0]), elementStatus26 },
+ { ARRAY_SIZE(elementStatus26), elementStatus26 },
};
static CONST_DATA_BLOB chain27[] = {
{ sizeof(chain27_0), chain27_0 },
@@ -3493,7 +3438,7 @@ static const CERT_TRUST_STATUS elementStatus27[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus27[] = {
- { sizeof(elementStatus27) / sizeof(elementStatus27[0]), elementStatus27 },
+ { ARRAY_SIZE(elementStatus27), elementStatus27 },
};
static const CERT_TRUST_STATUS elementStatus27Broken[] = {
{ CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER },
@@ -3502,7 +3447,7 @@ static const CERT_TRUST_STATUS elementStatus27Broken[] = {
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS },
};
static const SimpleChainStatusCheck simpleStatus27Broken[] = {
- { sizeof(elementStatus27Broken) / sizeof(elementStatus27Broken[0]),
+ { ARRAY_SIZE(elementStatus27Broken),
elementStatus27Broken },
};
static CONST_DATA_BLOB chain28[] = {
@@ -3515,7 +3460,7 @@ static const CERT_TRUST_STATUS elementStatus28[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus28[] = {
- { sizeof(elementStatus28) / sizeof(elementStatus28[0]), elementStatus28 },
+ { ARRAY_SIZE(elementStatus28), elementStatus28 },
};
static CONST_DATA_BLOB chain29[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3534,7 +3479,7 @@ static const CERT_TRUST_STATUS elementStatus30[] = {
CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus30[] = {
- { sizeof(elementStatus30) / sizeof(elementStatus30[0]), elementStatus30 },
+ { ARRAY_SIZE(elementStatus30), elementStatus30 },
};
static CONST_DATA_BLOB chain31[] = {
{ sizeof(chain0_0), chain0_0 },
@@ -3548,7 +3493,7 @@ static const CERT_TRUST_STATUS selfSignedElementStatus[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED },
};
static const SimpleChainStatusCheck selfSignedSimpleStatus[] = {
- { sizeof(selfSignedElementStatus) / sizeof(selfSignedElementStatus[0]),
+ { ARRAY_SIZE(selfSignedElementStatus),
selfSignedElementStatus },
};
static CONST_DATA_BLOB googleChain[] = {
@@ -3567,7 +3512,7 @@ static const CERT_TRUST_STATUS googleElementStatus[] = {
CERT_TRUST_HAS_KEY_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED |
CERT_TRUST_HAS_PREFERRED_ISSUER},
};
static const SimpleChainStatusCheck googleSimpleStatus[] = {
- { sizeof(googleElementStatus) / sizeof(googleElementStatus[0]),
+ { ARRAY_SIZE(googleElementStatus),
googleElementStatus },
};
static CONST_DATA_BLOB battlenetChain[] = {
@@ -3590,7 +3535,7 @@ static const CERT_TRUST_STATUS opensslElementStatus[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED},
};
static const SimpleChainStatusCheck opensslSimpleStatus[] = {
- { sizeof(opensslElementStatus) / sizeof(opensslElementStatus[0]),
+ { ARRAY_SIZE(opensslElementStatus),
opensslElementStatus },
};
/* The OpenSSL chain may not have its root trusted, in which case the chain
@@ -3605,7 +3550,7 @@ static const CERT_TRUST_STATUS incompleteOpensslElementStatus[] = {
{ CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_KEY_MATCH_ISSUER },
};
static const SimpleChainStatusCheck incompleteOpensslSimpleStatus[] = {
- { sizeof(incompleteOpensslElementStatus) / sizeof(incompleteOpensslElementStatus[0]),
+ { ARRAY_SIZE(incompleteOpensslElementStatus),
incompleteOpensslElementStatus },
};
/*
@@ -3625,7 +3570,7 @@ static const CERT_TRUST_STATUS stanfordElementStatus[] = {
CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED},
};
static const SimpleChainStatusCheck stanfordSimpleStatus[] = {
- { sizeof(stanfordElementStatus) / sizeof(stanfordElementStatus[0]),
+ { ARRAY_SIZE(stanfordElementStatus),
stanfordElementStatus },
};
static ChainCheck chainCheck[] = {
@@ -3634,23 +3579,23 @@ static ChainCheck chainCheck[] = {
* Windows 98/NT4 also set CERT_TRUST_IS_NOT_TIME_NESTED on chains they
* shouldn't, so ignore those too.
*/
- { { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { { ARRAY_SIZE(chain0), chain0 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_VALID, 0 },
1, simpleStatus0 }, 0, &oct2007 },
- { { sizeof(chain1) / sizeof(chain1[0]), chain1 },
+ { { ARRAY_SIZE(chain1), chain1 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_SIGNATURE_VALID |
CERT_TRUST_IS_NOT_TIME_VALID, 0 },
1, simpleStatus1 }, 0, &oct2007 },
- { { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { { ARRAY_SIZE(chain2), chain2 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_VALID, 0 },
1, simpleStatus2 }, 0, &oct2007 },
/* Earlier versions of Windows incorrectly don't set
* CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain.
*/
- { { sizeof(chain3) / sizeof(chain3[0]), chain3 },
+ { { ARRAY_SIZE(chain3), chain3 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT |
@@ -3659,7 +3604,7 @@ static ChainCheck chainCheck[] = {
/* Earlier versions of Windows incorrectly don't set
* CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain.
*/
- { { sizeof(chain4) / sizeof(chain4[0]), chain4 },
+ { { ARRAY_SIZE(chain4), chain4 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT |
@@ -3670,22 +3615,22 @@ static ChainCheck chainCheck[] = {
* Similarly, some older versions of Windows incorrectly set
* CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, ignore that too.
*/
- { { sizeof(chain5) / sizeof(chain5[0]), chain5 },
+ { { ARRAY_SIZE(chain5), chain5 },
{ { CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT |
CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus5 }, 0, &oct2007 },
- { { sizeof(chain6) / sizeof(chain6[0]), chain6 },
+ { { ARRAY_SIZE(chain6), chain6 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus6 }, 0, &oct2007 },
- { { sizeof(chain7) / sizeof(chain7[0]), chain7 },
+ { { ARRAY_SIZE(chain7), chain7 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus7 }, 0, &oct2007 },
/* Earlier versions of Windows incorrectly don't set
* CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain.
*/
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT |
@@ -3694,50 +3639,50 @@ static ChainCheck chainCheck[] = {
/* Earlier versions of Windows incorrectly don't set
* CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain.
*/
- { { sizeof(chain9) / sizeof(chain9[0]), chain9 },
+ { { ARRAY_SIZE(chain9), chain9 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_PARTIAL_CHAIN |
CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_CYCLIC, 0 },
1, simpleStatus9 }, 0, &oct2007 },
- { { sizeof(chain10) / sizeof(chain10[0]), chain10 },
+ { { ARRAY_SIZE(chain10), chain10 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus10 }, 0, &oct2007 },
- { { sizeof(chain11) / sizeof(chain11[0]), chain11 },
+ { { ARRAY_SIZE(chain11), chain11 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus10 }, 0, &oct2007 },
- { { sizeof(chain12) / sizeof(chain12[0]), chain12 },
+ { { ARRAY_SIZE(chain12), chain12 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_SIGNATURE_VALID, 0 },
1, simpleStatus12 }, 0, &oct2007 },
- { { sizeof(chain13) / sizeof(chain13[0]), chain13 },
+ { { ARRAY_SIZE(chain13), chain13 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus13 },
0, &oct2007 },
- { { sizeof(chain14) / sizeof(chain14[0]), chain14 },
+ { { ARRAY_SIZE(chain14), chain14 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus14 },
0, &oct2007 },
/* Earlier versions of crypt32 incorrectly do not complain that the end cert's
* key usage is invalid, so ignore that error.
*/
- { { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { { ARRAY_SIZE(chain15), chain15 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 },
1, simpleStatus15 },
0, &oct2007 },
- { { sizeof(chain16) / sizeof(chain16[0]), chain16 },
+ { { ARRAY_SIZE(chain16), chain16 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 },
1, simpleStatus16 },
0, &oct2007 },
- { { sizeof(chain17) / sizeof(chain17[0]), chain17 },
+ { { ARRAY_SIZE(chain17), chain17 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus17 },
0, &oct2007 },
- { { sizeof(chain18) / sizeof(chain18[0]), chain18 },
+ { { ARRAY_SIZE(chain18), chain18 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 },
@@ -3748,7 +3693,7 @@ static ChainCheck chainCheck[] = {
* They also do not set CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS, since they
* incorrectly find a name constraint error.
*/
- { { sizeof(chain19) / sizeof(chain19[0]), chain19 },
+ { { ARRAY_SIZE(chain19), chain19 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT,
CERT_TRUST_HAS_PREFERRED_ISSUER | CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS
@@ -3760,7 +3705,7 @@ static ChainCheck chainCheck[] = {
* CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, though they should. So
* ignore it (on Windows) but require it (on Wine.)
*/
- { { sizeof(chain20) / sizeof(chain20[0]), chain20 },
+ { { ARRAY_SIZE(chain20), chain20 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3769,7 +3714,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 },
1, simpleStatus20 },
0, &oct2007 },
- { { sizeof(chain21) / sizeof(chain21[0]), chain21 },
+ { { ARRAY_SIZE(chain21), chain21 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT,
CERT_TRUST_HAS_PREFERRED_ISSUER | CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS
@@ -3777,7 +3722,7 @@ static ChainCheck chainCheck[] = {
{ CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS },
1, simpleStatus21 },
0, &oct2007 },
- { { sizeof(chain22) / sizeof(chain22[0]), chain22 },
+ { { ARRAY_SIZE(chain22), chain22 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3786,7 +3731,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 },
1, simpleStatus22 },
0, &oct2007 },
- { { sizeof(chain23) / sizeof(chain23[0]), chain23 },
+ { { ARRAY_SIZE(chain23), chain23 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3795,7 +3740,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 },
1, simpleStatus23 },
0, &oct2007 },
- { { sizeof(chain24) / sizeof(chain24[0]), chain24 },
+ { { ARRAY_SIZE(chain24), chain24 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3804,7 +3749,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 },
1, simpleStatus24 },
0, &oct2007 },
- { { sizeof(chain25) / sizeof(chain25[0]), chain25 },
+ { { ARRAY_SIZE(chain25), chain25 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3813,7 +3758,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 },
1, simpleStatus25 },
0, &oct2007 },
- { { sizeof(chain26) / sizeof(chain26[0]), chain26 },
+ { { ARRAY_SIZE(chain26), chain26 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3823,7 +3768,7 @@ static ChainCheck chainCheck[] = {
1, simpleStatus26 },
0, &oct2007 },
/* chain27 is handled separately elsewhere */
- { { sizeof(chain28) / sizeof(chain28[0]), chain28 },
+ { { ARRAY_SIZE(chain28), chain28 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT,
@@ -3836,7 +3781,7 @@ static ChainCheck chainCheck[] = {
/* Microsoft incorrectly ignores unknown/unsupported critical extensions on
* older Windows versions, so ignore the error on Windows.
*/
- { { sizeof(chain30) / sizeof(chain30[0]), chain30 },
+ { { ARRAY_SIZE(chain30), chain30 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT |
@@ -3847,7 +3792,7 @@ static ChainCheck chainCheck[] = {
CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT, 0 },
1, simpleStatus30 },
0, &oct2007 },
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_UNTRUSTED_ROOT, 0 },
1, selfSignedSimpleStatus }, 0, &oct2007 },
@@ -3858,14 +3803,14 @@ static ChainCheck chainCheck[] = {
* e.g. has always CERT_TRUST_HAS_NAME_MATCH_ISSUER flag
* @see CRYPT_CheckSimpleChain
*/
- { { sizeof(googleChain) / sizeof(googleChain[0]), googleChain },
+ { { ARRAY_SIZE(googleChain), googleChain },
{ { 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 },
/* The stanford chain may or may not have its root trusted, so ignore the error
*/
- { { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain },
+ { { ARRAY_SIZE(stanfordChain), stanfordChain },
{ { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_NOT_TIME_VALID, 0 },
1, stanfordSimpleStatus }, 0, &oct2016 },
@@ -3875,16 +3820,16 @@ static const CERT_TRUST_STATUS elementStatus8NoStore[] = {
{ CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER },
};
static const SimpleChainStatusCheck simpleStatus8NoStore[] = {
- { sizeof(elementStatus8NoStore) / sizeof(elementStatus8NoStore[0]),
+ { ARRAY_SIZE(elementStatus8NoStore),
elementStatus8NoStore },
};
static ChainCheck chainCheckNoStore[] = {
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_UNTRUSTED_ROOT, 0 },
1, selfSignedSimpleStatus },
0 },
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ { 0, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_PARTIAL_CHAIN, 0 },
1, simpleStatus8NoStore },
@@ -3894,12 +3839,12 @@ static ChainCheck chainCheckNoStore[] = {
/* The openssl chain may or may not have its root trusted, so ignore the error
*/
static ChainCheck opensslChainCheck =
- { { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain },
+ { { ARRAY_SIZE(opensslChain), opensslChain },
{ { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_NOT_TIME_VALID, 0 },
1, opensslSimpleStatus }, 0 };
static ChainCheck incompleteOpensslChainCheck =
- { { sizeof(incompleteOpensslChain) / sizeof(incompleteOpensslChain[0]),
+ { { ARRAY_SIZE(incompleteOpensslChain),
incompleteOpensslChain },
{ { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_PARTIAL_CHAIN, 0 },
@@ -3912,7 +3857,7 @@ static ChainCheck incompleteOpensslChainCheck =
* on the chain's error status.
*/
static ChainCheck chainCheckEmbeddedNull = {
- { sizeof(chain27) / sizeof(chain27[0]), chain27 },
+ { ARRAY_SIZE(chain27), chain27 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
CERT_TRUST_HAS_PREFERRED_ISSUER },
{ CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_INVALID_NAME_CONSTRAINTS |
@@ -3920,7 +3865,7 @@ static ChainCheck chainCheckEmbeddedNull = {
1, simpleStatus27 },
0 };
static ChainCheck chainCheckEmbeddedNullBroken = {
- { sizeof(chain27) / sizeof(chain27[0]), chain27 },
+ { ARRAY_SIZE(chain27), chain27 },
{ { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT,
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS | CERT_TRUST_HAS_PREFERRED_ISSUER },
@@ -3928,25 +3873,6 @@ static ChainCheck chainCheckEmbeddedNullBroken = {
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS },
1, simpleStatus27Broken },
0 };
-static CONST_DATA_BLOB chainECDSA[] = {
- { sizeof(ecc_ca), ecc_ca },
- { sizeof(ecc_crt), ecc_crt },
-};
-static const CERT_TRUST_STATUS elementStatusECDSA[] = {
- { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER },
- { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_KEY_MATCH_ISSUER |
CERT_TRUST_IS_SELF_SIGNED },
-};
-static const SimpleChainStatusCheck simpleStatusECDSA[] = {
- { sizeof(elementStatusECDSA) / sizeof(elementStatusECDSA[0]), elementStatusECDSA },
-};
-static ChainCheck chainCheckECDSA = {
- { sizeof(chainECDSA) / sizeof(chainECDSA[0]), chainECDSA },
- {
- { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER },
- { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 },
- 1, simpleStatusECDSA
- }, 0
-};
#define test_name_blob(a,b) _test_name_blob(__LINE__,a,b)
static void _test_name_blob(unsigned line, CERT_NAME_BLOB *blob, const char *exdata)
@@ -4091,7 +4017,7 @@ static void testGetCertChain(void)
CertCloseStore(store, 0);
CertFreeCertificateContext(cert);
- for (i = 0; i < sizeof(chainCheck) / sizeof(chainCheck[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(chainCheck); i++)
{
chain = getChain(NULL, &chainCheck[i].certs, 0, TRUE,
chainCheck[i].validfor,
chainCheck[i].todo, i);
@@ -4124,8 +4050,7 @@ static void testGetCertChain(void)
0);
pCertFreeCertificateChain(chain);
}
- for (i = 0; i < sizeof(chainCheckNoStore) / sizeof(chainCheckNoStore[0]);
- i++)
+ for (i = 0; i < ARRAY_SIZE(chainCheckNoStore); i++)
{
chain = getChain(NULL, &chainCheckNoStore[i].certs, 0, FALSE, &oct2007,
chainCheckNoStore[i].todo, i);
@@ -4222,15 +4147,25 @@ static void testGetCertChain(void)
pCertFreeCertificateChain(chain);
- /* Test with ECDSA certificate */
- chain = getChain(NULL, &chainCheckECDSA.certs, 0, TRUE, &nov2017, FALSE, 0);
- if (chain)
- {
- ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_UNTRUSTED_ROOT,
- "unexpected chain error status %08x\n",
chain->TrustStatus.dwErrorStatus);
- checkChainStatus(chain, &chainCheckECDSA.status, chainCheckECDSA.todo,
"chainCheckECDSA", 0);
- pCertFreeCertificateChain(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);
+
+ 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);
+
+ 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);
/* Test HCCE_LOCAL_MACHINE */
ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store,
¶, 0, NULL, &chain);
@@ -4288,45 +4223,45 @@ typedef struct _ChainPolicyCheck
} ChainPolicyCheck;
static const ChainPolicyCheck basePolicyCheck[] = {
- { { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { { ARRAY_SIZE(chain0), chain0 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain1) / sizeof(chain1[0]), chain1 },
+ { { ARRAY_SIZE(chain1), chain1 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 },
- { { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { { ARRAY_SIZE(chain2), chain2 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain3) / sizeof(chain3[0]), chain3 },
+ { { ARRAY_SIZE(chain3), chain3 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain4) / sizeof(chain4[0]), chain4 },
+ { { ARRAY_SIZE(chain4), chain4 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain5) / sizeof(chain5[0]), chain5 },
+ { { ARRAY_SIZE(chain5), chain5 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain6) / sizeof(chain6[0]), chain6 },
+ { { ARRAY_SIZE(chain6), chain6 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain7) / sizeof(chain7[0]), chain7 },
+ { { ARRAY_SIZE(chain7), chain7 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain9) / sizeof(chain9[0]), chain9 },
+ { { ARRAY_SIZE(chain9), chain9 },
{ 0, CERT_E_CHAINING, 0, -1, NULL }, NULL, 0 },
- { { sizeof(chain10) / sizeof(chain10[0]), chain10 },
+ { { ARRAY_SIZE(chain10), chain10 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain11) / sizeof(chain11[0]), chain11 },
+ { { ARRAY_SIZE(chain11), chain11 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain12) / sizeof(chain12[0]), chain12 },
+ { { ARRAY_SIZE(chain12), chain12 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain13) / sizeof(chain13[0]), chain13 },
+ { { ARRAY_SIZE(chain13), chain13 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain14) / sizeof(chain14[0]), chain14 },
+ { { ARRAY_SIZE(chain14), chain14 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { { ARRAY_SIZE(chain15), chain15 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain16) / sizeof(chain16[0]), chain16 },
+ { { ARRAY_SIZE(chain16), chain16 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain17) / sizeof(chain17[0]), chain17 },
+ { { ARRAY_SIZE(chain17), chain17 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain18) / sizeof(chain18[0]), chain18 },
+ { { ARRAY_SIZE(chain18), chain18 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 },
};
@@ -4338,75 +4273,75 @@ static const CERT_CHAIN_POLICY_STATUS badDateNestingStatus =
{ 0, CERT_E_VALIDITYPERIODNESTING, 0, 0, NULL };
static const ChainPolicyCheck ignoredBadDateNestingBasePolicyCheck = {
- { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { ARRAY_SIZE(chain2), chain2 },
{ 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS
};
static const ChainPolicyCheck ignoredInvalidDateBasePolicyCheck = {
- { sizeof(googleChain) / sizeof(googleChain[0]), googleChain },
+ { ARRAY_SIZE(googleChain), googleChain },
{ 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS
};
static const ChainPolicyCheck ignoredInvalidUsageBasePolicyCheck = {
- { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { ARRAY_SIZE(chain15), chain15 },
{ 0, CERT_E_EXPIRED, 0, 1, NULL}, NULL, TODO_ERROR
};
static const ChainPolicyCheck invalidUsageBasePolicyCheck = {
- { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { ARRAY_SIZE(chain15), chain15 },
{ 0, CERT_E_WRONG_USAGE, 0, 1, NULL}, NULL, 0
};
static const ChainPolicyCheck sslPolicyCheck[] = {
- { { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { { ARRAY_SIZE(chain0), chain0 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain1) / sizeof(chain1[0]), chain1 },
+ { { ARRAY_SIZE(chain1), chain1 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 },
- { { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { { ARRAY_SIZE(chain2), chain2 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain3) / sizeof(chain3[0]), chain3 },
+ { { ARRAY_SIZE(chain3), chain3 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain4) / sizeof(chain4[0]), chain4 },
+ { { ARRAY_SIZE(chain4), chain4 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain5) / sizeof(chain5[0]), chain5 },
+ { { ARRAY_SIZE(chain5), chain5 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain6) / sizeof(chain6[0]), chain6 },
+ { { ARRAY_SIZE(chain6), chain6 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain7) / sizeof(chain7[0]), chain7 },
+ { { ARRAY_SIZE(chain7), chain7 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain9) / sizeof(chain9[0]), chain9 },
+ { { ARRAY_SIZE(chain9), chain9 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, -1, NULL }, NULL, 0 },
- { { sizeof(chain10) / sizeof(chain10[0]), chain10 },
+ { { ARRAY_SIZE(chain10), chain10 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain11) / sizeof(chain11[0]), chain11 },
+ { { ARRAY_SIZE(chain11), chain11 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain12) / sizeof(chain12[0]), chain12 },
+ { { ARRAY_SIZE(chain12), chain12 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain13) / sizeof(chain13[0]), chain13 },
+ { { ARRAY_SIZE(chain13), chain13 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain14) / sizeof(chain14[0]), chain14 },
+ { { ARRAY_SIZE(chain14), chain14 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { { ARRAY_SIZE(chain15), chain15 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain16) / sizeof(chain16[0]), chain16 },
+ { { ARRAY_SIZE(chain16), chain16 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain17) / sizeof(chain17[0]), chain17 },
+ { { ARRAY_SIZE(chain17), chain17 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain18) / sizeof(chain18[0]), chain18 },
+ { { ARRAY_SIZE(chain18), chain18 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 },
};
static const ChainPolicyCheck ignoredUnknownCAPolicyCheck = {
- { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { ARRAY_SIZE(chain0), chain0 },
{ 0, CERT_E_EXPIRED, 0, 0, NULL }, NULL, 0
};
static const ChainPolicyCheck googlePolicyCheckWithMatchingNameExpired = {
- { sizeof(googleChain) / sizeof(googleChain[0]), googleChain },
+ { ARRAY_SIZE(googleChain), googleChain },
{ 0, CERT_E_EXPIRED, 0, 0, NULL}, NULL, 0
};
@@ -4415,7 +4350,7 @@ static const CERT_CHAIN_POLICY_STATUS expiredStatus =
{ 0, CERT_E_EXPIRED, 0, 0, NULL };
static const ChainPolicyCheck googlePolicyCheckWithMatchingName = {
- { sizeof(googleChain) / sizeof(googleChain[0]), googleChain },
+ { ARRAY_SIZE(googleChain), googleChain },
{ 0, 0, -1, -1, NULL}, &expiredStatus, 0
};
@@ -4424,95 +4359,95 @@ static const CERT_CHAIN_POLICY_STATUS untrustedRootStatus =
{ 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL };
static const ChainPolicyCheck opensslPolicyCheckWithMatchingName = {
- { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain },
+ { ARRAY_SIZE(opensslChain), opensslChain },
{ 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0
};
static const ChainPolicyCheck opensslPolicyCheckWithoutMatchingName = {
- { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain },
+ { ARRAY_SIZE(opensslChain), opensslChain },
{ 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, &untrustedRootStatus, 0
};
static const ChainPolicyCheck winehqPolicyCheckWithMatchingName = {
- { sizeof(chain29) / sizeof(chain29[0]), chain29 },
+ { ARRAY_SIZE(chain29), chain29 },
{ 0, 0, -1, -1, NULL}, NULL, 0
};
static const ChainPolicyCheck winehqPolicyCheckWithoutMatchingName = {
- { sizeof(chain29) / sizeof(chain29[0]), chain29 },
+ { ARRAY_SIZE(chain29), chain29 },
{ 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, NULL, 0
};
static const ChainPolicyCheck stanfordPolicyCheckWithMatchingName = {
- { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain },
+ { ARRAY_SIZE(stanfordChain), stanfordChain },
{ 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0
};
static const ChainPolicyCheck stanfordPolicyCheckWithoutMatchingName = {
- { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain },
+ { ARRAY_SIZE(stanfordChain), stanfordChain },
{ 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, &untrustedRootStatus, 0
};
static const ChainPolicyCheck nullTerminatedDomainComponentPolicyCheck = {
- { sizeof(battlenetChain) / sizeof(battlenetChain[0]), battlenetChain },
+ { ARRAY_SIZE(battlenetChain), battlenetChain },
{ 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0
};
static const ChainPolicyCheck invalidExtensionPolicyCheck = {
- { sizeof(chain30) / sizeof(chain30[0]), chain30 },
+ { ARRAY_SIZE(chain30), chain30 },
{ 0, CERT_E_CRITICAL, 0, 1, NULL}, &badDateNestingStatus, 0
};
static const ChainPolicyCheck fooPolicyCheckWithMatchingName = {
- { sizeof(chain31) / sizeof(chain31[0]), chain31 },
+ { ARRAY_SIZE(chain31), chain31 },
{ 0, 0, -1, -1, NULL}, NULL, 0
};
static const ChainPolicyCheck fooPolicyCheckWithoutMatchingName = {
- { sizeof(chain31) / sizeof(chain31[0]), chain31 },
+ { ARRAY_SIZE(chain31), chain31 },
{ 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, NULL, 0
};
static const ChainPolicyCheck authenticodePolicyCheck[] = {
- { { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { { ARRAY_SIZE(chain0), chain0 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain1) / sizeof(chain1[0]), chain1 },
+ { { ARRAY_SIZE(chain1), chain1 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 },
- { { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { { ARRAY_SIZE(chain2), chain2 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain3) / sizeof(chain3[0]), chain3 },
+ { { ARRAY_SIZE(chain3), chain3 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain4) / sizeof(chain4[0]), chain4 },
+ { { ARRAY_SIZE(chain4), chain4 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain5) / sizeof(chain5[0]), chain5 },
+ { { ARRAY_SIZE(chain5), chain5 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain6) / sizeof(chain6[0]), chain6 },
+ { { ARRAY_SIZE(chain6), chain6 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain7) / sizeof(chain7[0]), chain7 },
+ { { ARRAY_SIZE(chain7), chain7 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain9) / sizeof(chain9[0]), chain9 },
+ { { ARRAY_SIZE(chain9), chain9 },
{ 0, CERT_E_CHAINING, 0, -1, NULL }, NULL, 0 },
- { { sizeof(chain10) / sizeof(chain10[0]), chain10 },
+ { { ARRAY_SIZE(chain10), chain10 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain11) / sizeof(chain11[0]), chain11 },
+ { { ARRAY_SIZE(chain11), chain11 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain12) / sizeof(chain12[0]), chain12 },
+ { { ARRAY_SIZE(chain12), chain12 },
{ 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain13) / sizeof(chain13[0]), chain13 },
+ { { ARRAY_SIZE(chain13), chain13 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain14) / sizeof(chain14[0]), chain14 },
+ { { ARRAY_SIZE(chain14), chain14 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { { ARRAY_SIZE(chain15), chain15 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain16) / sizeof(chain16[0]), chain16 },
+ { { ARRAY_SIZE(chain16), chain16 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain17) / sizeof(chain17[0]), chain17 },
+ { { ARRAY_SIZE(chain17), chain17 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(chain18) / sizeof(chain18[0]), chain18 },
+ { { ARRAY_SIZE(chain18), chain18 },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 },
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 },
};
@@ -4524,45 +4459,45 @@ static const CERT_CHAIN_POLICY_STATUS chain4BrokenStatus =
{ 0, TRUST_E_BASIC_CONSTRAINTS, 0, 2, NULL };
static const ChainPolicyCheck basicConstraintsPolicyCheck[] = {
- { { sizeof(chain0) / sizeof(chain0[0]), chain0 },
+ { { ARRAY_SIZE(chain0), chain0 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain1) / sizeof(chain1[0]), chain1 },
+ { { ARRAY_SIZE(chain1), chain1 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain2) / sizeof(chain2[0]), chain2 },
+ { { ARRAY_SIZE(chain2), chain2 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain3) / sizeof(chain3[0]), chain3 },
+ { { ARRAY_SIZE(chain3), chain3 },
{ 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain4) / sizeof(chain4[0]), chain4 },
+ { { ARRAY_SIZE(chain4), chain4 },
{ 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, &chain4BrokenStatus, 0 },
- { { sizeof(chain5) / sizeof(chain5[0]), chain5 },
+ { { ARRAY_SIZE(chain5), chain5 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain6) / sizeof(chain6[0]), chain6 },
+ { { ARRAY_SIZE(chain6), chain6 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain7) / sizeof(chain7[0]), chain7 },
+ { { ARRAY_SIZE(chain7), chain7 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain8) / sizeof(chain8[0]), chain8 },
+ { { ARRAY_SIZE(chain8), chain8 },
{ 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain9) / sizeof(chain9[0]), chain9 },
+ { { ARRAY_SIZE(chain9), chain9 },
{ 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 },
- { { sizeof(chain10) / sizeof(chain10[0]), chain10 },
+ { { ARRAY_SIZE(chain10), chain10 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain11) / sizeof(chain11[0]), chain11 },
+ { { ARRAY_SIZE(chain11), chain11 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain12) / sizeof(chain12[0]), chain12 },
+ { { ARRAY_SIZE(chain12), chain12 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain13) / sizeof(chain13[0]), chain13 },
+ { { ARRAY_SIZE(chain13), chain13 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain14) / sizeof(chain14[0]), chain14 },
+ { { ARRAY_SIZE(chain14), chain14 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain15) / sizeof(chain15[0]), chain15 },
+ { { ARRAY_SIZE(chain15), chain15 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain16) / sizeof(chain16[0]), chain16 },
+ { { ARRAY_SIZE(chain16), chain16 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain17) / sizeof(chain17[0]), chain17 },
+ { { ARRAY_SIZE(chain17), chain17 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(chain18) / sizeof(chain18[0]), chain18 },
+ { { ARRAY_SIZE(chain18), chain18 },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
- { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain },
+ { { ARRAY_SIZE(selfSignedChain), selfSignedChain },
{ 0, 0, -1, -1, NULL }, NULL, 0 },
};
@@ -4652,7 +4587,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE
engine,
#define CHECK_CHAIN_POLICY_STATUS_ARRAY(policy, engine, array, date, para) \
do { \
DWORD i; \
- for (i = 0; i < sizeof(array) / sizeof(array)[0]; i++) \
+ for (i = 0; i < ARRAY_SIZE(array); i++) \
checkChainPolicyStatus((policy), (engine), &(array)[i], \
#array, i, (date), (para)); \
} while(0)
diff --git a/modules/rostests/winetests/crypt32/encode.c
b/modules/rostests/winetests/crypt32/encode.c
index ad39a35606..4a6626ab00 100644
--- a/modules/rostests/winetests/crypt32/encode.c
+++ b/modules/rostests/winetests/crypt32/encode.c
@@ -113,7 +113,7 @@ static void test_encodeInt(DWORD dwEncoding)
ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
"Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
}
- for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ints); i++)
{
/* encode as normal integer */
ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0,
@@ -155,7 +155,7 @@ static void test_encodeInt(DWORD dwEncoding)
/* encode a couple bigger ints, just to show it's little-endian and leading
* sign bytes are dropped
*/
- for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bigInts); i++)
{
blob.cbData = strlen((const char*)bigInts[i].val);
blob.pbData = (BYTE *)bigInts[i].val;
@@ -178,7 +178,7 @@ static void test_encodeInt(DWORD dwEncoding)
}
}
/* and, encode some uints */
- for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bigUInts); i++)
{
blob.cbData = strlen((const char*)bigUInts[i].val);
blob.pbData = (BYTE*)bigUInts[i].val;
@@ -242,7 +242,7 @@ static void test_decodeInt(DWORD dwEncoding)
GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n",
GetLastError());
- for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ints); i++)
{
/* When the output buffer is NULL, this always succeeds */
SetLastError(0xdeadbeef);
@@ -264,7 +264,7 @@ static void test_decodeInt(DWORD dwEncoding)
LocalFree(buf);
}
}
- for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bigInts); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER,
bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL,
@@ -289,7 +289,7 @@ static void test_decodeInt(DWORD dwEncoding)
LocalFree(buf);
}
}
- for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bigUInts); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT,
bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL,
@@ -377,9 +377,9 @@ static void test_encodeEnumerated(DWORD dwEncoding)
{
DWORD i, j;
- for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++)
{
- for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(enums); j++)
{
BOOL ret;
BYTE *buf = NULL;
@@ -410,9 +410,9 @@ static void test_decodeEnumerated(DWORD dwEncoding)
{
DWORD i, j;
- for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++)
{
- for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(enums); j++)
{
BOOL ret;
DWORD bufSize = sizeof(int);
@@ -563,7 +563,7 @@ static void test_encodeFiletime(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(times) / sizeof(times[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(times); i++)
{
testTimeEncoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]);
testTimeEncoding(dwEncoding, PKCS_UTC_TIME, ×[i]);
@@ -645,19 +645,19 @@ static void test_decodeFiletime(DWORD dwEncoding)
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
/* Normal tests */
- for (i = 0; i < sizeof(times) / sizeof(times[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(times); i++)
{
testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]);
testTimeDecoding(dwEncoding, PKCS_UTC_TIME, ×[i]);
testTimeDecoding(dwEncoding, szOID_RSA_signingTime, ×[i]);
}
- for (i = 0; i < sizeof(otherTimes) / sizeof(otherTimes[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(otherTimes); i++)
{
testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, &otherTimes[i]);
testTimeDecoding(dwEncoding, PKCS_UTC_TIME, &otherTimes[i]);
testTimeDecoding(dwEncoding, szOID_RSA_signingTime, &otherTimes[i]);
}
- for (i = 0; i < sizeof(bogusTimes) / sizeof(bogusTimes[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bogusTimes); i++)
{
size = sizeof(ft1);
ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME,
@@ -861,7 +861,7 @@ static void test_encodeName(DWORD dwEncoding)
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Test a more complex name */
- rdn.cRDNAttr = sizeof(rdnAttrs) / sizeof(rdnAttrs[0]);
+ rdn.cRDNAttr = ARRAY_SIZE(rdnAttrs);
rdn.rgRDNAttr = rdnAttrs;
info.cRDN = 1;
info.rgRDN = &rdn;
@@ -1139,7 +1139,7 @@ static void test_decodeName(DWORD dwEncoding)
(BYTE *)commonName } },
};
- rdn.cRDNAttr = sizeof(attrs) / sizeof(attrs[0]);
+ rdn.cRDNAttr = ARRAY_SIZE(attrs);
rdn.rgRDNAttr = attrs;
compareNames(&info, (CERT_NAME_INFO *)buf);
LocalFree(buf);
@@ -1157,7 +1157,7 @@ static void test_decodeName(DWORD dwEncoding)
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
if (ret)
{
- rdn.cRDNAttr = sizeof(decodedRdnAttrs) / sizeof(decodedRdnAttrs[0]);
+ rdn.cRDNAttr = ARRAY_SIZE(decodedRdnAttrs);
rdn.rgRDNAttr = decodedRdnAttrs;
compareNames(&info, (CERT_NAME_INFO *)buf);
LocalFree(buf);
@@ -1223,7 +1223,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
{ lstrlenW(commonNameW) * sizeof(WCHAR), (BYTE *)commonNameW } },
};
- rdn.cRDNAttr = sizeof(attrs) / sizeof(attrs[0]);
+ rdn.cRDNAttr = ARRAY_SIZE(attrs);
rdn.rgRDNAttr = attrs;
compareNames(&info, (CERT_NAME_INFO *)buf);
LocalFree(buf);
@@ -1332,7 +1332,7 @@ static void test_encodeNameValue(DWORD dwEncoding)
"Unexpected encoding\n");
LocalFree(buf);
}
- for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(nameValues); i++)
{
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE,
&nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
@@ -1370,7 +1370,7 @@ static void test_decodeNameValue(DWORD dwEncoding)
DWORD bufSize = 0;
BOOL ret;
- for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(nameValues); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE,
nameValues[i].encoded, nameValues[i].encoded[1] + 2,
@@ -1866,7 +1866,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
"Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
/* More failure checking */
value.Value.cbData = 0;
- for (i = 0; i < sizeof(unicodeErrors) / sizeof(unicodeErrors[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(unicodeErrors); i++)
{
value.Value.pbData = (LPBYTE)unicodeErrors[i].str;
value.dwValueType = unicodeErrors[i].valueType;
@@ -1881,7 +1881,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
}
/* cbData can be zero if the string is NULL-terminated */
value.Value.cbData = 0;
- for (i = 0; i < sizeof(unicodeResults) / sizeof(unicodeResults[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(unicodeResults); i++)
{
value.Value.pbData = (LPBYTE)unicodeResults[i].str;
value.dwValueType = unicodeResults[i].valueType;
@@ -1903,7 +1903,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
* rather than properly encoding it. Kept separate from the proper results,
* because the encoded forms won't decode to their original strings.
*/
- for (i = 0; i < sizeof(unicodeWeirdness) / sizeof(unicodeWeirdness[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(unicodeWeirdness); i++)
{
value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str;
value.dwValueType = unicodeWeirdness[i].valueType;
@@ -1933,7 +1933,7 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(unicodeResults) / sizeof(unicodeResults[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(unicodeResults); i++)
{
BYTE *buf = NULL;
BOOL ret;
@@ -1991,7 +1991,7 @@ static void test_encodeOctets(DWORD dwEncoding)
}
};
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
BYTE *buf = NULL;
BOOL ret;
@@ -2065,7 +2065,7 @@ static void test_decodeOctets(DWORD dwEncoding)
}
};
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
BYTE *buf = NULL;
BOOL ret;
@@ -2127,7 +2127,7 @@ static void test_encodeBits(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bits); i++)
{
CRYPT_BIT_BLOB blob;
BOOL ret;
@@ -2162,7 +2162,7 @@ static void test_decodeBits(DWORD dwEncoding)
DWORD bufSize = 0;
/* normal cases */
- for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(bits); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded,
bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
@@ -2249,7 +2249,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
BYTE *buf = NULL;
/* First test with the simpler info2 */
- for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(constraints2); i++)
{
ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2,
&constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
@@ -2312,7 +2312,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
DWORD bufSize = 0;
/* First test with simpler info2 */
- for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(constraints2); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2,
constraints2[i].encoded, constraints2[i].encoded[1] + 2,
@@ -2494,7 +2494,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
/* Finally, all valid */
hdr->aiKeyAlg = CALG_RSA_KEYX;
- for (i = 0; i < sizeof(rsaPubKeys) / sizeof(rsaPubKeys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
{
memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY),
rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen);
@@ -2540,7 +2540,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding)
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
/* Now try success cases */
- for (i = 0; i < sizeof(rsaPubKeys) / sizeof(rsaPubKeys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
{
bufSize = 0;
ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
@@ -2590,7 +2590,7 @@ static const BYTE mixedSequence[] = { 0x30, 0x27, 0x17, 0x0d, 0x30,
0x35, 0x30,
static void test_encodeSequenceOfAny(DWORD dwEncoding)
{
- CRYPT_DER_BLOB blobs[sizeof(ints) / sizeof(ints[0])];
+ CRYPT_DER_BLOB blobs[ARRAY_SIZE(ints)];
CRYPT_SEQUENCE_OF_ANY seq;
DWORD i;
BOOL ret;
@@ -2598,12 +2598,12 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding)
DWORD bufSize = 0;
/* Encode a homogeneous sequence */
- for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ints); i++)
{
blobs[i].cbData = ints[i].encoded[1] + 2;
blobs[i].pbData = (BYTE *)ints[i].encoded;
}
- seq.cValue = sizeof(ints) / sizeof(ints[0]);
+ seq.cValue = ARRAY_SIZE(ints);
seq.rgValue = blobs;
ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
@@ -2646,9 +2646,8 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding)
CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
DWORD i;
- ok(seq->cValue == sizeof(ints) / sizeof(ints[0]),
- "Wrong elements %d\n", seq->cValue);
- for (i = 0; i < min(seq->cValue, sizeof(ints) / sizeof(ints[0])); i++)
+ ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\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,
@@ -2666,8 +2665,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding)
{
CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
- ok(seq->cValue == sizeof(ints) / sizeof(ints[0]),
- "Wrong elements %d\n", seq->cValue);
+ ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\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,
@@ -2713,7 +2711,7 @@ static void test_encodeExtensions(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++)
+ for (i = 0; i < ARRAY_SIZE(exts); i++)
{
BOOL ret;
BYTE *buf = NULL;
@@ -2737,7 +2735,7 @@ static void test_decodeExtensions(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++)
+ for (i = 0; i < ARRAY_SIZE(exts); i++)
{
BOOL ret;
BYTE *buf = NULL;
@@ -2851,7 +2849,7 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding)
{
DWORD i;
- for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(pubKeys); i++)
{
BOOL ret;
BYTE *buf = NULL;
@@ -2907,7 +2905,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding)
BYTE *buf = NULL;
DWORD bufSize = 0;
- for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(pubKeys); i++)
{
/* The NULL form decodes to the decoded member */
ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO,
@@ -3260,7 +3258,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
* 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 < sizeof(corruptCerts) / sizeof(corruptCerts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(corruptCerts); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED,
corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
@@ -4688,7 +4686,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
BYTE *buf = NULL;
DWORD size = 0, i;
- for (i = 0; i < sizeof(corruptCRLs) / sizeof(corruptCRLs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(corruptCRLs); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
@@ -4854,7 +4852,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
LocalFree(buf);
}
/* Test with a few usages */
- usage.cUsageIdentifier = sizeof(keyUsages) / sizeof(keyUsages[0]);
+ usage.cUsageIdentifier = ARRAY_SIZE(keyUsages);
usage.rgpszUsageIdentifier = (LPSTR *)keyUsages;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
@@ -4898,8 +4896,8 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
ok(size >= sizeof(CERT_ENHKEY_USAGE),
"Wrong size %d\n", size);
- ok(usage->cUsageIdentifier == sizeof(keyUsages) / sizeof(keyUsages[0]),
- "Wrong CRL entries count %d\n", usage->cUsageIdentifier);
+ ok(usage->cUsageIdentifier == ARRAY_SIZE(keyUsages),
+ "Wrong CRL entries count %d\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],
@@ -6109,7 +6107,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding)
"1.2.3", content_constructed_abcd + 8, 10 }
};
- for (i = 0; i < sizeof(tests)/sizeof(*tests); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded,
tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
@@ -7397,9 +7395,7 @@ static void test_decodeNameConstraints(DWORD dwEncoding)
U(IPAddressWithMinSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr;
U(IPAddressWithMinMaxSubtree.Base).IPAddress.cbData = sizeof(encodedIPAddr);
U(IPAddressWithMinMaxSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr;
- for (i = 0;
- i < sizeof(encodedNameConstraints) / sizeof(encodedNameConstraints[0]);
- i++)
+ for (i = 0; i < ARRAY_SIZE(encodedNameConstraints); i++)
{
DWORD size;
@@ -7749,7 +7745,7 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding)
DWORD size, i;
/* Each of the mapping OIDs is equivalent, so check with all of them */
- for (i = 0; i < sizeof(mappingOids) / sizeof(mappingOids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(mappingOids); i++)
{
memset(&info, 0, sizeof(info));
ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
@@ -7814,7 +7810,7 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
BOOL ret;
/* Each of the mapping OIDs is equivalent, so check with all of them */
- for (i = 0; i < sizeof(mappingOids) / sizeof(mappingOids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(mappingOids); i++)
{
ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
@@ -8509,173 +8505,6 @@ static void testPortPublicKeyInfo(void)
ok(ret,"CryptAcquireContextA failed\n");
}
-static const BYTE eccCert[] = {
-0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b,
-0x26,0x86,0x0a,0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86,
-0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09,
-0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,
-0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65,
-0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57,
-0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32,
-0x37,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x17,0x0d,0x32,0x37,
-0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x30,
-0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
-0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,
-0x04,0x54,0x65,0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,
-0x04,0x03,0x0c,0x04,0x54,0x65,0x73,0x74,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,0xed,
-0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f,
-0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60,
-0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb,0x6d,0x74,0xe9,0x7b,
-0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9,0x07,0x7e,0x7b,
-0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15,
-0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,
-0x04,0x03,0x02,0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7,
-0x29,0xce,0x5a,0xef,0x74,0x85,0xd1,0x18,0x5f,0x6e,0xf1,0xba,
-0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48,0x51,0xea,0x63,
-0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94,
-0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a,
-0x5a,0x50,0x29,0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02,
-0x92,0x21,0x4c,0x2c,0x92,0xee };
-static const BYTE ecdsaSig[] = {
-0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85,
-0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d,
-0xf1,0x5e,0x48,0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,
-0xaf,0x02,0x21,0x00,0xe3,0x94,0x15,0x3b,0x6c,0x71,0x6e,0x44,
-0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29,0x7c,0x5c,0xd6,
-0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee };
-static const BYTE eccPubKey[] = {
-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,0xed,0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,
-0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d,
-0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb,
-0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,
-0xb9,0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,
-0xce,0xa2,0x57,0x15,0xad,0xc5,0x1f };
-
-static void testECDSACert(void)
-{
- DWORD decode_flags = CRYPT_DECODE_ALLOC_FLAG |
CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG;
- CERT_SIGNED_CONTENT_INFO *info;
- CERT_PUBLIC_KEY_INFO *pubkey;
- CERT_ECC_SIGNATURE *ecc_sig;
- LPSTR *ecc_curve;
- DWORD size;
- BOOL ret;
- int i;
-
- info = NULL;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert),
decode_flags,
- NULL, &info, &size);
- ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError());
-
- ok(!strcmp(info->SignatureAlgorithm.pszObjId, szOID_ECDSA_SHA256),
- "Expected 1.2.840.10045.4.3.2, got %s\n",
info->SignatureAlgorithm.pszObjId);
- ok(!info->SignatureAlgorithm.Parameters.cbData,
- "Expected no parameter data, got %d bytes\n",
info->SignatureAlgorithm.Parameters.cbData);
- ok(!info->SignatureAlgorithm.Parameters.pbData,
- "Expected no parameter data, got %p pointer\n",
info->SignatureAlgorithm.Parameters.pbData);
-
- ok(info->Signature.cbData == sizeof(ecdsaSig),
- "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig),
info->Signature.cbData);
- ok(info->Signature.pbData != NULL, "Got NULL pointer\n");
- ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n",
info->Signature.cUnusedBits);
- for (i = 0; i < info->Signature.cbData; i++)
- {
- ok(ecdsaSig[i] == info->Signature.pbData[i], "Expected %02x, got %02x at
offset %d\n",
- ecdsaSig[i], info->Signature.pbData[i], i);
- }
-
- ecc_sig = NULL;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE,
info->Signature.pbData,
- info->Signature.cbData, decode_flags, NULL,
&ecc_sig, &size);
- ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError());
- if (ret)
- {
- ok(ecc_sig->r.cbData == 32, "Expected 32 bytes, got %d\n",
ecc_sig->r.cbData);
- ok(ecc_sig->r.pbData != NULL, "Got NULL pointer\n");
- ok(ecc_sig->s.cbData == 32, "Expected 32 bytes, got %d\n",
ecc_sig->s.cbData);
- ok(ecc_sig->s.pbData != NULL, "Got NULL pointer\n");
- for (i = 0; i < ecc_sig->r.cbData; i++)
- {
- ok(ecdsaSig[4+32-i] == ecc_sig->r.pbData[i], "Expected %02x, got %02x
at offset %d\n",
- ecdsaSig[4+32-i], ecc_sig->r.pbData[i], i);
- }
- for (i = 0; i < ecc_sig->s.cbData; i++)
- {
- ok(ecdsaSig[4+35+32-i] == ecc_sig->s.pbData[i], "Expected %02x, got
%02x at offset %d\n",
- ecdsaSig[4+35+32-i], ecc_sig->s.pbData[i], i);
- }
- LocalFree(ecc_sig);
- }
-
- LocalFree(info);
-
- info = NULL;
- decode_flags &= ~CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert),
decode_flags,
- NULL, &info, &size);
- ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError());
-
- ok(info->Signature.cbData == sizeof(ecdsaSig),
- "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig),
info->Signature.cbData);
- ok(info->Signature.pbData != NULL, "Got NULL pointer\n");
- ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n",
info->Signature.cUnusedBits);
- for (i = 0; i < info->Signature.cbData; i++)
- {
- ok(ecdsaSig[sizeof(ecdsaSig)-i-1] == info->Signature.pbData[i], "Expected
%02x, got %02x at offset %d\n",
- ecdsaSig[sizeof(ecdsaSig)-i-1], info->Signature.pbData[i], i);
- }
-
- LocalFree(info);
-
- pubkey = NULL;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, eccPubKey,
sizeof(eccPubKey),
- decode_flags, NULL, &pubkey, &size);
- ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError());
-
- ok(!strcmp(pubkey->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY),
- "Expected 1.2.840.10045.2.1, got %s\n", pubkey->Algorithm.pszObjId);
- ok(pubkey->Algorithm.Parameters.cbData == 10,
- "Expected 10 bytes parameters, got %d bytes\n",
pubkey->Algorithm.Parameters.cbData);
- ok(pubkey->Algorithm.Parameters.pbData != NULL,
- "Expected pointer to parameters, got NULL\n");
-
- ecc_curve = NULL;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER,
pubkey->Algorithm.Parameters.pbData,
- pubkey->Algorithm.Parameters.cbData, decode_flags,
NULL, &ecc_curve, &size);
- ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */),
- "CryptDecodeObjectEx failed with %d\n", GetLastError());
- if (ret)
- {
- ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7,
got %s\n", *ecc_curve);
- LocalFree(ecc_curve);
- }
-
- ecc_curve = NULL;
- ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, szOID_ECC_PUBLIC_KEY,
pubkey->Algorithm.Parameters.pbData,
- pubkey->Algorithm.Parameters.cbData, decode_flags,
NULL, &ecc_curve, &size);
- ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */),
- "CryptDecodeObjectEx failed with %d\n", GetLastError());
- if (ret)
- {
- ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7,
got %s\n", *ecc_curve);
- LocalFree(ecc_curve);
- }
-
- ok(pubkey->PublicKey.cbData == 65, "Expected 32 bytes parameters, got %d
bytes\n", pubkey->PublicKey.cbData);
- ok(pubkey->PublicKey.pbData != NULL, "Expected pointer to parameters, got
NULL\n");
- for (i = 0; i < pubkey->PublicKey.cbData; i++)
- {
- ok(eccPubKey[26+i] == pubkey->PublicKey.pbData[i], "Expected %02x, got
%02x at offset %d\n",
- eccPubKey[26+i], pubkey->PublicKey.pbData[i], i);
- }
-
- LocalFree(pubkey);
-}
-
START_TEST(encode)
{
static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING,
@@ -8692,7 +8521,7 @@ START_TEST(encode)
return;
}
- for (i = 0; i < sizeof(encodings) / sizeof(encodings[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(encodings); i++)
{
test_encodeInt(encodings[i]);
test_decodeInt(encodings[i]);
@@ -8769,5 +8598,4 @@ START_TEST(encode)
test_decodeRsaPrivateKey(encodings[i]);
}
testPortPublicKeyInfo();
- testECDSACert();
}
diff --git a/modules/rostests/winetests/crypt32/main.c
b/modules/rostests/winetests/crypt32/main.c
index a0019b5869..11beff11c4 100644
--- a/modules/rostests/winetests/crypt32/main.c
+++ b/modules/rostests/winetests/crypt32/main.c
@@ -36,7 +36,7 @@ static void test_findAttribute(void)
BYTE blobbin[] = {0x02,0x01,0x01};
static CHAR oid[] = "1.2.3";
CRYPT_ATTR_BLOB blobs[] = { { sizeof blobbin, blobbin }, };
- CRYPT_ATTRIBUTE attr = { oid, sizeof(blobs) / sizeof(blobs[0]), blobs };
+ CRYPT_ATTRIBUTE attr = { oid, ARRAY_SIZE(blobs), blobs };
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
@@ -128,10 +128,8 @@ static void test_findRDNAttr(void)
CERT_RDN_ATTR attrs[] = {
{ oid, CERT_RDN_IA5_STRING, { sizeof bin, bin } },
};
- CERT_RDN rdns[] = {
- { sizeof(attrs) / sizeof(attrs[0]), attrs },
- };
- CERT_NAME_INFO nameInfo = { sizeof(rdns) / sizeof(rdns[0]), rdns };
+ CERT_RDN rdns[] = { { ARRAY_SIZE(attrs), attrs } };
+ CERT_NAME_INFO nameInfo = { ARRAY_SIZE(rdns), rdns };
if (0)
{
diff --git a/modules/rostests/winetests/crypt32/msg.c
b/modules/rostests/winetests/crypt32/msg.c
index c2405335b9..b6921273ee 100644
--- a/modules/rostests/winetests/crypt32/msg.c
+++ b/modules/rostests/winetests/crypt32/msg.c
@@ -575,7 +575,7 @@ static CRYPT_DATA_BLOB b1[] = {
{ sizeof(u2), u2 },
{ sizeof(u2), u2 },
};
-static const struct update_accum a1 = { sizeof(b1) / sizeof(b1[0]), b1 };
+static const struct update_accum a1 = { ARRAY_SIZE(b1), b1 };
/* The updates of a definite-length encoded message */
static BYTE u3[] = { 0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
0x07,0x01,0xa0,0x06,0x04,0x04 };
@@ -583,7 +583,7 @@ static CRYPT_DATA_BLOB b2[] = {
{ sizeof(u3), u3 },
{ sizeof(u2), u2 },
};
-static const struct update_accum a2 = { sizeof(b2) / sizeof(b2[0]), b2 };
+static const struct update_accum a2 = { ARRAY_SIZE(b2), b2 };
/* The updates of an indefinite-length encoded message */
static BYTE u4[] = { 0x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
0x07,0x01,0xa0,0x80,0x24,0x80 };
@@ -597,7 +597,7 @@ static CRYPT_DATA_BLOB b3[] = {
{ sizeof(u2), u2 },
{ sizeof(u6), u6 },
};
-static const struct update_accum a3 = { sizeof(b3) / sizeof(b3[0]), b3 };
+static const struct update_accum a3 = { ARRAY_SIZE(b3), b3 };
static void check_updates(LPCSTR header, const struct update_accum *expected,
const struct update_accum *got)
diff --git a/modules/rostests/winetests/crypt32/oid.c
b/modules/rostests/winetests/crypt32/oid.c
index 89d58b77f8..d6a03c5d1d 100644
--- a/modules/rostests/winetests/crypt32/oid.c
+++ b/modules/rostests/winetests/crypt32/oid.c
@@ -106,7 +106,7 @@ static void testOIDToAlgID(void)
alg = CertOIDToAlgId("1.2.3");
ok(!alg, "Expected failure, got %d\n", alg);
- for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++)
+ 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),
@@ -124,7 +124,7 @@ static void testAlgIDToOID(void)
oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80);
ok(!oid && GetLastError() == 0xdeadbeef,
"Didn't expect last error (%08x) to be set\n", GetLastError());
- for (i = 0; i < sizeof(algIDToOID) / sizeof(algIDToOID[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(algIDToOID); i++)
{
oid = CertAlgIdToOID(algIDToOID[i].algID);
/* Allow failure, not every version of Windows supports every algo */
@@ -424,7 +424,7 @@ static void test_registerDefaultOIDFunction(void)
DWORD type, size;
LPSTR ptr;
- size = sizeof(dllBuf) / sizeof(dllBuf[0]);
+ size = ARRAY_SIZE(dllBuf);
rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size);
ok(rc == 0,
"Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc);
@@ -547,86 +547,63 @@ 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_ecda_sha25[] = szOID_ECDSA_SHA256;
+ static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256;
ALG_ID alg = CALG_SHA1;
ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN };
+ const struct oid_info
+ {
+ DWORD key_type;
+ void *key;
+ const char *oid;
+ ALG_ID algid;
+ ALG_ID broken_algid;
+ } 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_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 },
+ };
PCCRYPT_OID_INFO info;
-
- static const WCHAR sha256W[] =
{'s','h','a','2','5','6',0};
+ int i;
info = CryptFindOIDInfo(0, NULL, 0);
ok(info == NULL, "Expected NULL\n");
- info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, 0);
- ok(info != NULL, "Expected to find szOID_RSA_MD5\n");
- if (info)
- {
- ok(!strcmp(info->pszOID, szOID_RSA_MD5), "Expected %s, got %s\n",
- szOID_RSA_MD5, info->pszOID);
- ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n",
- U(*info).Algid);
- }
- info = CryptFindOIDInfo(CRYPT_OID_INFO_NAME_KEY, sha1, 0);
- ok(info != NULL, "Expected to find sha1\n");
- if (info)
- {
- ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got
%s\n",
- szOID_OIWSEC_sha1, info->pszOID);
- ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n",
- U(*info).Algid);
- }
- info = CryptFindOIDInfo(CRYPT_OID_INFO_ALGID_KEY, &alg, 0);
- ok(info != NULL, "Expected to find sha1\n");
- if (info)
- {
- ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got
%s\n",
- szOID_OIWSEC_sha1, info->pszOID);
- ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n",
- U(*info).Algid);
- }
- info = CryptFindOIDInfo(CRYPT_OID_INFO_SIGN_KEY, algs, 0);
- ok(info != NULL, "Expected to find md5RSA\n");
- if (info)
- {
- ok(!strcmp(info->pszOID, szOID_RSA_MD5RSA), "Expected %s, got
%s\n",
- szOID_RSA_MD5RSA, info->pszOID);
- ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n",
- U(*info).Algid);
- }
- info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_sha256, 0);
- ok(info != NULL, "Expected to find szOID_RSA_MD5\n");
- if (info)
+ for (i = 0; i < ARRAY_SIZE(oid_test_info); i++)
{
- ok(!strcmp(info->pszOID, szOID_NIST_sha256), "Expected %s, got
%s\n",
- szOID_NIST_sha256, info->pszOID);
- ok(!lstrcmpW(info->pwszName, sha256W), "pwszName = %s\n",
wine_dbgstr_w(info->pwszName));
- ok(U(*info).Algid == CALG_SHA_256 || U(*info).Algid == -1,
- "Expected CALG_MD5 or -1, got %d\n", U(*info).Algid);
+ const struct oid_info *test = &oid_test_info[i];
+
+ info = CryptFindOIDInfo(test->key_type, test->key, 0);
+ ok(info != NULL, "Failed to find %s.\n", test->oid);
+ 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);
+ }
}
- info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecda_sha25, 0);
+ info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecdsa_sha256, 0);
if (info)
{
DWORD *data;
- ok(info->cbSize == sizeof(*info),
- "Expected %d, got %d\n", (int)sizeof(*info), info->cbSize);
- ok(!strcmp(info->pszOID, oid_ecda_sha25),
- "Expected %s, got %s\n", oid_ecda_sha25, info->pszOID);
- ok(!lstrcmpW(info->pwszName, sha256ECDSA),
- "Expected %s, got %s\n", wine_dbgstr_w(sha256ECDSA),
wine_dbgstr_w(info->pwszName));
+ ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\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(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);
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 %d\n",
info->ExtraInfo.cbData);
+ ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS,
got %x\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 %x\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));
diff --git a/modules/rostests/winetests/crypt32/sip.c
b/modules/rostests/winetests/crypt32/sip.c
index e2ec2f411d..d8d6a87445 100644
--- a/modules/rostests/winetests/crypt32/sip.c
+++ b/modules/rostests/winetests/crypt32/sip.c
@@ -187,9 +187,8 @@ static void test_SIPRetrieveSubjectGUID(void)
ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n",
GetLastError());
strcat(regeditPath, "\\");
strcat(regeditPath, regeditExe);
- MultiByteToWideChar( CP_ACP, 0, regeditPath,
- strlen(regeditPath)+1, regeditPathW,
- sizeof(regeditPathW)/sizeof(regeditPathW[0]) );
+ MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW,
+ ARRAY_SIZE(regeditPathW));
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
@@ -221,9 +220,7 @@ static void test_SIPRetrieveSubjectGUID(void)
/* Now with an empty file */
GetTempPathA(sizeof(path), path);
GetTempFileNameA(path, "sip", 0 , tempfile);
- MultiByteToWideChar( CP_ACP, 0, tempfile,
- strlen(tempfile)+1, tempfileW,
- sizeof(tempfileW)/sizeof(tempfileW[0]) );
+ MultiByteToWideChar(CP_ACP, 0, tempfile, strlen(tempfile)+1, tempfileW,
ARRAY_SIZE(tempfileW));
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
diff --git a/modules/rostests/winetests/crypt32/store.c
b/modules/rostests/winetests/crypt32/store.c
index 47cd0b38cd..9915482277 100644
--- a/modules/rostests/winetests/crypt32/store.c
+++ b/modules/rostests/winetests/crypt32/store.c
@@ -385,7 +385,7 @@ static void testRegStoreSavedCerts(void)
BOOL ret;
DWORD res,i;
- for (i = 0; i < sizeof(reg_store_saved_certs) / sizeof(reg_store_saved_certs[0]);
i++)
+ for (i = 0; i < ARRAY_SIZE(reg_store_saved_certs); i++)
{
DWORD err;
@@ -2081,7 +2081,7 @@ static void testCertRegisterSystemStore(void)
const CERT_CONTEXT *cert, *cert2;
unsigned int i;
- for (i = 0; i < sizeof(reg_system_store_test_data) /
sizeof(reg_system_store_test_data[0]); 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);
if (!ret)
@@ -2469,7 +2469,7 @@ static void delete_test_key(void)
RegQueryInfoKeyW(test_key, NULL, NULL, NULL, &num_subkeys, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
for (idx = num_subkeys; idx-- > 0;)
{
- subkey_name_len = sizeof(subkey_name)/sizeof(WCHAR);
+ subkey_name_len = ARRAY_SIZE(subkey_name);
RegEnumKeyExW(test_key, idx, subkey_name, &subkey_name_len, NULL, NULL, NULL,
NULL);
RegDeleteKeyW(test_key, subkey_name);
}
diff --git a/modules/rostests/winetests/crypt32/str.c
b/modules/rostests/winetests/crypt32/str.c
index 5245885503..d382c0e6b0 100644
--- a/modules/rostests/winetests/crypt32/str.c
+++ b/modules/rostests/winetests/crypt32/str.c
@@ -250,7 +250,7 @@ static void test_CertRDNValueToStrA(void)
ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty
string\n");
ok(!buffer[0], "Expected empty string\n");
- for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs); i++)
{
ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value,
buffer, sizeof(buffer));
@@ -341,15 +341,13 @@ static void test_CertRDNValueToStrW(void)
SetLastError(0xdeadbeef);
ret = pCertRDNValueToStrW(0, &blob, NULL, 0);
ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty
string\n");
- ret = pCertRDNValueToStrW(0, &blob, buffer,
- sizeof(buffer) / sizeof(buffer[0]));
+ ret = pCertRDNValueToStrW(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 < sizeof(attrs) / sizeof(attrs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs); i++)
{
- ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value,
- buffer, sizeof(buffer) / sizeof(buffer[0]));
+ 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,
@@ -550,8 +548,7 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD
dwStrType,
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,
- sizeof(buffer) / sizeof(buffer[0]));
+ 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);
@@ -795,7 +792,7 @@ static void test_CertStrToNameA(void)
&size, NULL);
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"Expected ERROR_MORE_DATA, got %08x\n", GetLastError());
- for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(namesA); i++)
{
size = sizeof(buf);
ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf,
@@ -889,7 +886,7 @@ static void test_CertStrToNameW(void)
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ok(errorPtr && *errorPtr == '1', "Expected first error character
was 1\n");
- for (i = 0; i < sizeof(namesW) / sizeof(namesW[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(namesW); i++)
{
size = sizeof(buf);
ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,