Commit 353cd81c authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32/tests: Win64 printf format warning fixes.

parent d62c50bc
......@@ -4,7 +4,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = crypt32.dll
IMPORTS = crypt32 advapi32 kernel32
EXTRADEFS = -DWINE_NO_LONG_AS_INT
CTESTS = \
base64.c \
......
......@@ -96,7 +96,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
BOOL ret;
ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
str = HeapAlloc(GetProcessHeap(), 0, strLen);
if (str)
{
......@@ -105,8 +105,8 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, str,
&strLen2);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(strLen2 == strLen - 1, "Expected length %ld, got %ld\n",
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
ok(strLen2 == strLen - 1, "Expected length %d, got %d\n",
strLen - 1, strLen);
if (header)
{
......@@ -136,10 +136,10 @@ static void testBinaryToStringA(void)
ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, &strLen);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
{
DWORD strLen = 0;
......@@ -148,7 +148,7 @@ static void testBinaryToStringA(void)
ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BINARY, NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
str = HeapAlloc(GetProcessHeap(), 0, strLen);
if (str)
{
......@@ -156,7 +156,7 @@ static void testBinaryToStringA(void)
ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
CRYPT_STRING_BINARY, str, &strLen2);
ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen,
ok(strLen == strLen2, "Expected length %d, got %d\n", strLen,
strLen2);
ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen),
"Unexpected value\n");
......@@ -183,7 +183,7 @@ static void testBinaryToStringA(void)
ret = pCryptBinaryToStringA(testsNoCR[i].toEncode,
testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR,
NULL, &strLen);
ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
str = HeapAlloc(GetProcessHeap(), 0, strLen);
if (str)
{
......@@ -192,7 +192,7 @@ static void testBinaryToStringA(void)
ret = pCryptBinaryToStringA(testsNoCR[i].toEncode,
testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR,
str, &strLen2);
ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen,
ok(strLen == strLen2, "Expected length %d, got %d\n", strLen,
strLen2);
ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen),
"Unexpected value\n");
......@@ -245,7 +245,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
strcat(str, trailer);
ret = pCryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL,
NULL);
ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
if (buf)
{
......@@ -254,16 +254,16 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
/* check as normal, make sure last two parameters are optional */
ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL,
NULL);
ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
ok(bufLen == expectedLen,
"Expected length %ld, got %ld\n", expectedLen, bufLen);
"Expected length %d, got %d\n", expectedLen, bufLen);
ok(!memcmp(buf, expected, bufLen), "Unexpected value\n");
/* check last two params */
ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
&skipped, &usedFormat);
ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
ok(skipped == 0, "Expected skipped 0, got %ld\n", skipped);
ok(usedFormat == expectedFormat, "Expected format %ld, got %ld\n",
ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
ok(skipped == 0, "Expected skipped 0, got %d\n", skipped);
ok(usedFormat == expectedFormat, "Expected format %d, got %d\n",
expectedFormat, usedFormat);
HeapFree(GetProcessHeap(), 0, buf);
}
......@@ -279,10 +279,10 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
NULL);
/* expect failure with no header, and success with one */
if (header)
ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
else
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %ld\n", GetLastError());
"Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
if (ret)
{
buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
......@@ -293,7 +293,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
&skipped, &usedFormat);
ok(skipped == strlen(garbage),
"Expected %d characters skipped, got %ld\n", lstrlenA(garbage),
"Expected %d characters skipped, got %d\n", lstrlenA(garbage),
skipped);
HeapFree(GetProcessHeap(), 0, buf);
}
......@@ -324,20 +324,20 @@ static void testStringToBinaryA(void)
ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
/* Bogus format */
ret = pCryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL,
NULL);
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %ld\n", GetLastError());
"Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
/* Decoding doesn't expect the NOCR flag to be specified */
ret = pCryptStringToBinaryA(tests[0].base64, 1,
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, NULL, &bufLen, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %ld\n", GetLastError());
"Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
/* Bad strings */
for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++)
{
......@@ -345,7 +345,7 @@ static void testStringToBinaryA(void)
ret = pCryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format,
NULL, &bufLen, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %ld\n", GetLastError());
"Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
}
/* Good strings */
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
......@@ -356,7 +356,7 @@ static void testStringToBinaryA(void)
*/
ret = pCryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64,
NULL, &bufLen, NULL, NULL);
todo_wine ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
todo_wine ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
/* Check with the precise format */
decodeAndCompareBase64_A(tests[i].base64, NULL, NULL,
CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, tests[i].toEncode,
......@@ -410,7 +410,7 @@ static void testStringToBinaryA(void)
*/
ret = pCryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64,
NULL, &bufLen, NULL, NULL);
todo_wine ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
todo_wine ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
/* Check with the precise format */
decodeAndCompareBase64_A(testsNoCR[i].base64, NULL, NULL,
CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, testsNoCR[i].toEncode,
......
......@@ -65,21 +65,21 @@ static void testCreateCertChainEngine(void)
*/
ret = CertCreateCertificateChainEngine(&config, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertCreateCertificateChainEngine(&config, &engine);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Crashes
config.cbSize = sizeof(config);
ret = CertCreateCertificateChainEngine(&config, NULL);
*/
config.cbSize = sizeof(config);
ret = CertCreateCertificateChainEngine(&config, &engine);
ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
CertFreeCertificateChainEngine(engine);
config.dwFlags = 0xff000000;
ret = CertCreateCertificateChainEngine(&config, &engine);
ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
CertFreeCertificateChainEngine(engine);
/* Creating a cert with no root certs at all is allowed.. */
......@@ -87,7 +87,7 @@ static void testCreateCertChainEngine(void)
CERT_STORE_CREATE_NEW_FLAG, NULL);
config.hRestrictedRoot = store;
ret = CertCreateCertificateChainEngine(&config, &engine);
ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
CertFreeCertificateChainEngine(engine);
/* but creating one with a restricted root with a cert that isn't a member
......@@ -97,7 +97,7 @@ static void testCreateCertChainEngine(void)
sizeof(selfSignedCert), CERT_STORE_ADD_ALWAYS, NULL);
ret = CertCreateCertificateChainEngine(&config, &engine);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertCloseStore(store, 0);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -42,7 +42,7 @@ static void test_findAttribute(void)
SetLastError(0xdeadbeef);
ret = CertFindAttribute(NULL, 0, NULL);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* crashes
SetLastError(0xdeadbeef);
......@@ -52,24 +52,24 @@ static void test_findAttribute(void)
SetLastError(0xdeadbeef);
ret = CertFindAttribute(NULL, 1, &attr);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("bogus", 1, &attr);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("1.2.4", 1, &attr);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("1.2.3", 1, &attr);
ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError());
ok(ret != NULL, "CertFindAttribute failed: %08x\n", GetLastError());
}
static void test_findExtension(void)
......@@ -83,7 +83,7 @@ static void test_findExtension(void)
SetLastError(0xdeadbeef);
ret = CertFindExtension(NULL, 0, NULL);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* crashes
SetLastError(0xdeadbeef);
......@@ -93,24 +93,24 @@ static void test_findExtension(void)
SetLastError(0xdeadbeef);
ret = CertFindExtension(NULL, 1, &ext);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("bogus", 1, &ext);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("1.2.4", 1, &ext);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("1.2.3", 1, &ext);
ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError());
ok(ret != NULL, "CertFindExtension failed: %08x\n", GetLastError());
}
static void test_findRDNAttr(void)
......@@ -134,24 +134,24 @@ static void test_findRDNAttr(void)
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr(NULL, &nameInfo);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("bogus", &nameInfo);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("1.2.4", &nameInfo);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("1.2.3", &nameInfo);
ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError());
ok(ret != NULL, "CertFindRDNAttr failed: %08x\n", GetLastError());
}
static void test_verifyTimeValidity(void)
......@@ -169,16 +169,16 @@ static void test_verifyTimeValidity(void)
*/
/* Check with 0 NotBefore and NotAfter */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 1, "Expected 1, got %ld\n", ret);
ok(ret == 1, "Expected 1, got %d\n", ret);
memcpy(&info.NotAfter, &fileTime, sizeof(info.NotAfter));
/* Check with NotAfter equal to comparison time */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 0, "Expected 0, got %ld\n", ret);
ok(ret == 0, "Expected 0, got %d\n", ret);
/* Check with NotBefore after comparison time */
memcpy(&info.NotBefore, &fileTime, sizeof(info.NotBefore));
info.NotBefore.dwLowDateTime += 5000;
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == -1, "Expected -1, got %ld\n", ret);
ok(ret == -1, "Expected -1, got %d\n", ret);
}
static void test_cryptAllocate(void)
......@@ -186,13 +186,13 @@ static void test_cryptAllocate(void)
LPVOID buf;
buf = CryptMemAlloc(0);
ok(buf != NULL, "CryptMemAlloc failed: %08lx\n", GetLastError());
ok(buf != NULL, "CryptMemAlloc failed: %08x\n", GetLastError());
CryptMemFree(buf);
buf = CryptMemRealloc(NULL, 0);
ok(!buf, "Expected NULL\n");
buf = CryptMemAlloc(0);
buf = CryptMemRealloc(buf, 1);
ok(buf != NULL, "CryptMemRealloc failed: %08lx\n", GetLastError());
ok(buf != NULL, "CryptMemRealloc failed: %08x\n", GetLastError());
CryptMemFree(buf);
}
......@@ -228,7 +228,7 @@ static void test_cryptTls(void)
/* One normal pass */
index = pI_CryptAllocTls();
ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
if (index)
{
LPVOID ptr;
......@@ -236,24 +236,24 @@ static void test_cryptTls(void)
ptr = pI_CryptGetTls(index);
ok(!ptr, "Expected NULL\n");
ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
ptr = pI_CryptGetTls(index);
ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
/* This crashes
ret = pI_CryptFreeTls(index, 1);
*/
ret = pI_CryptFreeTls(index, 0);
ok(ret, "I_CryptFreeTls failed: %08lx\n", GetLastError());
ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
ret = pI_CryptFreeTls(index, 0);
/* Not sure if this fails because TlsFree should fail, so leave as
* todo for now.
*/
todo_wine ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
}
/* Similar pass, check I_CryptDetachTls */
index = pI_CryptAllocTls();
ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
if (index)
{
LPVOID ptr;
......@@ -261,7 +261,7 @@ static void test_cryptTls(void)
ptr = pI_CryptGetTls(index);
ok(!ptr, "Expected NULL\n");
ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
ptr = pI_CryptGetTls(index);
ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
ptr = pI_CryptDetachTls(index);
......@@ -312,7 +312,7 @@ static void test_readTrustedPublisherDWORD(void)
ret = pReadDWORD(authenticodeFlags, &returnedFlags);
ok(ret == exists, "Unexpected return value\n");
ok(readFlags == returnedFlags,
"Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
"Expected flags %08x, got %08x\n", readFlags, returnedFlags);
}
}
......@@ -331,15 +331,15 @@ static void test_getDefaultCryptProv(void)
prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(1);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(0);
ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError());
ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError());
CryptReleaseContext(prov, 0);
}
......
......@@ -52,13 +52,13 @@ static void test_cryptprotectdata(void)
protected = CryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher);
ok(!protected, "Encrypting without plain data source.\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
SetLastError(0xDEADBEEF);
protected = CryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL);
ok(!protected, "Encrypting without cipher destination.\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
cipher.pbData=NULL;
cipher.cbData=0;
......@@ -68,7 +68,7 @@ static void test_cryptprotectdata(void)
protected = CryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher);
ok(protected, "Encrypting without entropy.\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
cipher_entropy.pbData=NULL;
cipher_entropy.cbData=0;
......@@ -78,7 +78,7 @@ static void test_cryptprotectdata(void)
protected = CryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy);
ok(protected, "Encrypting with entropy.\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
cipher_no_desc.pbData=NULL;
cipher_no_desc.cbData=0;
......@@ -90,7 +90,7 @@ static void test_cryptprotectdata(void)
protected = CryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc);
ok(protected, "Encrypting with entropy and no description.\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
}
static void test_cryptunprotectdata(void)
......@@ -114,13 +114,13 @@ static void test_cryptunprotectdata(void)
okay = CryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL);
ok(!okay,"Decrypting without destination\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
SetLastError(0xDEADBEEF);
okay = CryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain);
ok(!okay,"Decrypting without source\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
plain.pbData=NULL;
plain.cbData=0;
......@@ -129,7 +129,7 @@ static void test_cryptunprotectdata(void)
okay = CryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain);
ok(!okay,"Decrypting without needed entropy\n");
r = GetLastError();
ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n", r);
ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n", r);
plain.pbData=NULL;
plain.cbData=0;
......@@ -140,7 +140,7 @@ static void test_cryptunprotectdata(void)
okay = CryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain);
ok(okay,"Decrypting without entropy\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
......@@ -160,14 +160,14 @@ static void test_cryptunprotectdata(void)
okay = CryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain);
ok(!okay,"Decrypting with wrong entropy\n");
r = GetLastError();
ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n",r);
/* with entropy */
SetLastError(0xDEADBEEF);
okay = CryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
......@@ -187,7 +187,7 @@ static void test_cryptunprotectdata(void)
okay = CryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy and no description\n");
r = GetLastError();
ok(r == ERROR_SUCCESS, "Wrong (%lu) GetLastError seen\n",r);
ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret2)+1,"Plain DATA_BLOB wrong length\n");
......
......@@ -231,7 +231,7 @@ static void test_CertRDNValueToStrA(void)
{
ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value,
buffer, sizeof(buffer));
ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %ld\n",
ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %d\n",
lstrlenA(attrs[i].str) + 1, ret);
ok(!strcmp(buffer, attrs[i].str), "Expected %s, got %s\n", attrs[i].str,
buffer);
......@@ -289,7 +289,7 @@ static void test_CertRDNValueToStrW(void)
{
ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value,
buffer, sizeof(buffer) / sizeof(buffer[0]));
ok(ret == lstrlenW(attrs[i].str) + 1, "Expected length %d, got %ld\n",
ok(ret == lstrlenW(attrs[i].str) + 1, "Expected length %d, got %d\n",
lstrlenW(attrs[i].str) + 1, ret);
ok(!lstrcmpW(buffer, attrs[i].str), "Unexpected value\n");
#ifdef DUMP_STRINGS
......@@ -306,11 +306,11 @@ static void test_NameToStrConversionA(PCERT_NAME_BLOB pName, DWORD dwStrType,
DWORD i;
i = pCertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0);
ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n",
ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
lstrlenA(expected) + 1, i);
i = pCertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer,
sizeof(buffer));
ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n",
ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
lstrlenA(expected) + 1, i);
ok(!strcmp(buffer, expected), "Expected %s, got %s\n", expected, buffer);
}
......@@ -323,7 +323,7 @@ static void test_CertNameToStrA(void)
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
if (context)
{
......@@ -336,13 +336,13 @@ static void test_CertNameToStrA(void)
SetLastError(0xdeadbeef);
ret = pCertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0);
ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n",
"Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pCertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
0, NULL, 0);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n",
"Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
ret, GetLastError());
test_NameToStrConversionA(&context->pCertInfo->Issuer,
......@@ -375,11 +375,11 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
DWORD i;
i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0);
ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
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]));
ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
lstrlenW(expected) + 1, i);
ok(!lstrcmpW(buffer, expected), "Unexpected value\n");
#ifdef DUMP_STRINGS
......@@ -396,7 +396,7 @@ static void test_CertNameToStrW(void)
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
if (context)
{
......@@ -409,13 +409,13 @@ static void test_CertNameToStrW(void)
SetLastError(0xdeadbeef);
ret = pCertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0);
ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n",
"Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pCertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
0, NULL, 0);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n",
"Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
ret, GetLastError());
test_NameToStrConversionW(&context->pCertInfo->Issuer,
......@@ -482,33 +482,33 @@ static void test_CertStrToNameA(void)
ok(!ret, "Expected failure\n");
ret = pCertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL);
ok(ret, "CertStrToNameA failed: %08lx\n", GetLastError());
ok(ret, "CertStrToNameA failed: %08x\n", GetLastError());
size = sizeof(buf);
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"\"1\"\"", 0, NULL, buf, &size,
NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf,
&size, NULL);
todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++)
{
size = sizeof(buf);
ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf,
&size, NULL);
ok(ret, "CertStrToNameA failed on string %s: %08lx\n", namesA[i].x500,
ok(ret, "CertStrToNameA failed on string %s: %08x\n", namesA[i].x500,
GetLastError());
ok(size == namesA[i].encodedSize,
"Expected size %ld, got %ld\n", namesA[i].encodedSize, size);
"Expected size %d, got %d\n", namesA[i].encodedSize, size);
if (ret)
ok(!memcmp(buf, namesA[i].encoded, namesA[i].encodedSize),
"Unexpected value for string %s\n", namesA[i].x500);
......@@ -563,38 +563,38 @@ static void test_CertStrToNameW(void)
ok(!ret, "Expected failure\n");
ret = pCertStrToNameW(0, bogusW, 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameW(0, fooW, 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameW(0, simpleCN_W, 0, NULL, NULL, &size, NULL);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
ret = pCertStrToNameW(X509_ASN_ENCODING, simpleCN_W, 0, NULL, NULL, &size,
NULL);
ok(ret, "CertStrToNameW failed: %08lx\n", GetLastError());
ok(ret, "CertStrToNameW failed: %08x\n", GetLastError());
size = sizeof(buf);
ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
&size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
&size, &errorPtr);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
"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++)
{
size = sizeof(buf);
ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,
&size, NULL);
ok(ret, "Index %ld: CertStrToNameW failed: %08lx\n", i, GetLastError());
ok(ret, "Index %d: CertStrToNameW failed: %08x\n", i, GetLastError());
ok(size == namesW[i].encodedSize,
"Index %ld: expected size %ld, got %ld\n", i, namesW[i].encodedSize,
"Index %d: expected size %d, got %d\n", i, namesW[i].encodedSize,
size);
if (ret)
ok(!memcmp(buf, namesW[i].encoded, size),
"Index %ld: unexpected value\n", i);
"Index %d: unexpected value\n", i);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment