crypt32/tests: Win64 printf format warning fixes.

This commit is contained in:
Juan Lang 2006-09-29 14:36:26 -07:00 committed by Alexandre Julliard
parent d62c50bc86
commit 353cd81c9a
11 changed files with 907 additions and 908 deletions

View File

@ -4,7 +4,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = crypt32.dll
IMPORTS = crypt32 advapi32 kernel32
EXTRADEFS = -DWINE_NO_LONG_AS_INT
CTESTS = \
base64.c \

View File

@ -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,

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

View File

@ -94,26 +94,26 @@ static void testCreateCRL(void)
context = CertCreateCRLContext(0, NULL, 0);
ok(!context && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
context = CertCreateCRLContext(X509_ASN_ENCODING, NULL, 0);
ok(!context && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
context = CertCreateCRLContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
ok(!context && GetLastError() == CRYPT_E_ASN1_CORRUPT,
"Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
"Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError());
context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL) - 1);
ok(!context && (GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == CRYPT_E_ASN1_CORRUPT),
"Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n",
"Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08x\n",
GetLastError());
context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL));
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
if (context)
CertFreeCRLContext(context);
context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL));
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
if (context)
CertFreeCRLContext(context);
}
@ -130,50 +130,50 @@ static void testAddCRL(void)
/* Bad CRL encoding type */
ret = CertAddEncodedCRLToStore(0, 0, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL), 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL), 0,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* No CRL */
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
/* Weird--bad add disposition leads to an access violation in Windows. */
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
"Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
"Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
"Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
"Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
/* Weird--can add a CRL to the NULL store (does this have special meaning?)
*/
context = NULL;
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
if (context)
CertFreeCRLContext(context);
@ -183,17 +183,17 @@ static void testAddCRL(void)
/* and an unsigned one is too. */
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, CRL, sizeof(CRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
sizeof(newerCRL), CERT_STORE_ADD_NEW, NULL);
ok(!ret && GetLastError() == CRYPT_E_EXISTS,
"Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
"Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
/* This should replace (one of) the existing CRL(s). */
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
sizeof(newerCRL), CERT_STORE_ADD_NEWER, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
CertCloseStore(store, 0);
}
@ -210,7 +210,7 @@ static void testFindCRL(void)
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
/* Crashes
context = CertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL);
@ -241,7 +241,7 @@ static void testFindCRL(void)
/* Try to match an issuer that isn't in the store */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
sizeof(bigCert2));
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
ok(context == NULL, "Expected no matching context\n");
@ -250,7 +250,7 @@ static void testFindCRL(void)
/* Match an issuer that is in the store */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
ok(context != NULL, "Expected a context\n");
@ -281,17 +281,17 @@ static void testGetCRLFromStore(void)
flags = 0xffffffff;
context = CertGetCRLFromStore(store, NULL, NULL, &flags);
ok(!context && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Test an empty store */
flags = 0;
context = CertGetCRLFromStore(store, NULL, NULL, &flags);
ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
/* NULL matches any CRL */
flags = 0;
@ -302,17 +302,17 @@ static void testGetCRLFromStore(void)
/* This cert's issuer isn't in */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
sizeof(bigCert2));
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
context = CertGetCRLFromStore(store, cert, NULL, &flags);
ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertFreeCertificateContext(cert);
/* But this one is */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
context = CertGetCRLFromStore(store, cert, NULL, &flags);
ok(context != NULL, "Expected a context\n");
@ -333,10 +333,10 @@ static void checkCRLHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
memset(hashProperty, 0, sizeof(hashProperty));
size = sizeof(hash);
ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
ret = CertGetCRLContextProperty(context, propID, hashProperty, &size);
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n",
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n",
propID);
}
@ -345,7 +345,7 @@ static void testCRLProperties(void)
PCCRL_CONTEXT context = CertCreateCRLContext(X509_ASN_ENCODING,
CRL, sizeof(CRL));
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
if (context)
{
DWORD propID, numProps, access, size;
@ -364,12 +364,12 @@ static void testCRLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
/* Tests with a NULL cert context. Prop ID 0 fails.. */
ret = CertSetCRLContextProperty(NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* while this just crashes.
ret = CertSetCRLContextProperty(NULL, CERT_KEY_PROV_HANDLE_PROP_ID, 0,
NULL);
@ -377,7 +377,7 @@ static void testCRLProperties(void)
ret = CertSetCRLContextProperty(context, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Can't set the cert property directly, this crashes.
ret = CertSetCRLContextProperty(context, CERT_CRL_PROP_ID, 0, CRL);
*/
@ -394,14 +394,14 @@ static void testCRLProperties(void)
ret = CertGetCRLContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID,
NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
/* And, an implicit property */
ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
NULL, &size);
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
&access, &size);
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
"Didn't expect a persisted crl\n");
/* Trying to set this "read only" property crashes.
@ -414,7 +414,7 @@ static void testCRLProperties(void)
blob.pbData = hash;
blob.cbData = sizeof(hash);
ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, &blob);
ok(ret, "CertSetCRLContextProperty failed: %08lx\n",
ok(ret, "CertSetCRLContextProperty failed: %08x\n",
GetLastError());
size = sizeof(hashProperty);
ret = CertGetCRLContextProperty(context, CERT_HASH_PROP_ID,
@ -422,7 +422,7 @@ static void testCRLProperties(void)
ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
/* Delete the (bogus) hash, and get the real one */
ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, NULL);
ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError());
ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError());
checkCRLHash(CRL, sizeof(CRL), CALG_SHA1, context, CERT_HASH_PROP_ID);
/* Now that the hash property is set, we should get one property when
@ -435,7 +435,7 @@ static void testCRLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
/* Check a few other implicit properties */
checkCRLHash(CRL, sizeof(CRL), CALG_MD5, context,
@ -505,10 +505,10 @@ static void testIsValidCRLForCert(void)
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
sizeof(v1CRLWithIssuerAndEntry));
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert1 != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert1 != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
/* Crash
@ -518,15 +518,15 @@ static void testIsValidCRLForCert(void)
/* Curiously, any CRL is valid for the NULL certificate */
ret = pCertIsValidCRLForCertificate(NULL, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
/* Same issuer for both cert and CRL, this CRL is valid for that cert */
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
cert2 = CertCreateCertificateContext(X509_ASN_ENCODING,
bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer));
ok(cert2 != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert2 != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
/* Yet more curious: different issuers for these, yet the CRL is valid for
@ -534,7 +534,7 @@ static void testIsValidCRLForCert(void)
* CRL has a CRL_ISSUING_DIST_POINT extension.
*/
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
CertFreeCRLContext(crl);
@ -543,24 +543,24 @@ static void testIsValidCRLForCert(void)
*/
crl = CertCreateCRLContext(X509_ASN_ENCODING, v2CRLWithIssuingDistPoint,
sizeof(v2CRLWithIssuingDistPoint));
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
CertFreeCRLContext(crl);
/* And again, with a real CRL, the CRL is valid for both certs. */
crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL));
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
CertFreeCRLContext(crl);
@ -569,16 +569,16 @@ static void testIsValidCRLForCert(void)
*/
store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, &crl);
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
CertFreeCRLContext(crl);
@ -604,7 +604,7 @@ static void testFindCertInCRL(void)
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
GetLastError());
/* Crash
@ -620,14 +620,14 @@ static void testFindCertInCRL(void)
crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL));
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ok(entry == NULL, "Expected not to find an entry in CRL\n");
CertFreeCRLContext(crl);
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
sizeof(v1CRLWithIssuerAndEntry));
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ok(entry != NULL, "Expected to find an entry in CRL\n");
CertFreeCRLContext(crl);
@ -635,7 +635,7 @@ static void testFindCertInCRL(void)
crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer,
sizeof(crlWithDifferentIssuer));
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ok(entry != NULL, "Expected to find an entry in CRL\n");
CertFreeCRLContext(crl);
@ -649,18 +649,18 @@ static void testVerifyCRLRevocation(void)
PCCRL_CONTEXT crl;
ret = CertVerifyCRLRevocation(0, NULL, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, NULL, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
/* Check against no CRL */
ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
/* Check against CRL with entry for the cert */
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
@ -676,7 +676,7 @@ static void testVerifyCRLRevocation(void)
/* Check against CRL with different issuer and entry for the cert */
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
sizeof(v1CRLWithIssuerAndEntry));
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(!ret, "CertVerifyCRLRevocation should have been revoked\n");
@ -687,10 +687,10 @@ static void testVerifyCRLRevocation(void)
sizeof(verisignCRL));
ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
CertFreeCRLContext(crl);
CertFreeCertificateContext(cert);

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

View File

@ -94,7 +94,7 @@ static void testOIDToAlgID(void)
alg = CertOIDToAlgId("1.2.3");
ok(!alg && (GetLastError() == 0xdeadbeef ||
GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND),
"Expected ERROR_RESOURCE_NAME_NOT_FOUND or no error set, got %08lx\n",
"Expected ERROR_RESOURCE_NAME_NOT_FOUND or no error set, got %08x\n",
GetLastError());
for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++)
@ -104,7 +104,7 @@ static void testOIDToAlgID(void)
* at least not the wrong one.
*/
ok(alg == 0 || alg == oidToAlgID[i].algID,
"Expected %ld, got %ld\n", oidToAlgID[i].algID, alg);
"Expected %d, got %d\n", oidToAlgID[i].algID, alg);
}
}
@ -117,7 +117,7 @@ static void testAlgIDToOID(void)
SetLastError(0xdeadbeef);
oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80);
ok(!oid && GetLastError() == 0xdeadbeef,
"Didn't expect last error (%08lx) to be set\n", GetLastError());
"Didn't expect last error (%08x) to be set\n", GetLastError());
for (i = 0; i < sizeof(algIDToOID) / sizeof(algIDToOID[0]); i++)
{
oid = CertAlgIdToOID(algIDToOID[i].algID);
@ -141,7 +141,7 @@ static void test_oidFunctionSet(void)
/* The name doesn't mean much */
set1 = CryptInitOIDFunctionSet("funky", 0);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
if (set1)
{
/* These crash
@ -150,14 +150,14 @@ static void test_oidFunctionSet(void)
*/
size = 0;
ret = CryptGetDefaultOIDDllList(set1, 0, NULL, &size);
ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n", GetLastError());
ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n", GetLastError());
if (ret)
{
buf = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
if (buf)
{
ret = CryptGetDefaultOIDDllList(set1, 0, buf, &size);
ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n",
ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n",
GetLastError());
ok(!*buf, "Expected empty DLL list\n");
HeapFree(GetProcessHeap(), 0, buf);
@ -167,9 +167,9 @@ static void test_oidFunctionSet(void)
/* MSDN says flags must be 0, but it's not checked */
set1 = CryptInitOIDFunctionSet("", 1);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
set2 = CryptInitOIDFunctionSet("", 0);
ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
/* There isn't a free function, so there must be only one set per name to
* limit leaks. (I guess the sets are freed when crypt32 is unloaded.)
*/
@ -183,7 +183,7 @@ static void test_oidFunctionSet(void)
/* There's no installed function for a built-in encoding. */
set1 = CryptInitOIDFunctionSet("CryptDllEncodeObject", 0);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
if (set1)
{
void *funcAddr;
@ -192,7 +192,7 @@ static void test_oidFunctionSet(void)
ret = CryptGetOIDFunctionAddress(set1, X509_ASN_ENCODING, X509_CERT, 0,
&funcAddr, &hFuncAddr);
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());
}
}
@ -217,21 +217,21 @@ static void test_installOIDFunctionAddress(void)
SetLastError(0xdeadbeef);
ret = CryptInstallOIDFunctionAddress(NULL, 0, "CryptDllEncodeObject", 0,
NULL, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
GetLastError());
/* The function name doesn't much matter */
SetLastError(0xdeadbeef);
ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 0, NULL, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
GetLastError());
SetLastError(0xdeadbeef);
entry.pszOID = X509_CERT;
ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 1, &entry, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
GetLastError());
set = CryptInitOIDFunctionSet("OhSoFunky", 0);
ok(set != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
ok(set != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
if (set)
{
funcY funcAddr = NULL;
@ -244,14 +244,14 @@ static void test_installOIDFunctionAddress(void)
ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0,
(void **)&funcAddr, &hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0,
(void **)&funcAddr, &hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
ret = CryptGetOIDFunctionAddress(set, 0, X509_CERT, 0,
(void **)&funcAddr, &hFuncAddr);
ok(ret, "CryptGetOIDFunctionAddress failed: %ld\n", GetLastError());
ok(ret, "CryptGetOIDFunctionAddress failed: %d\n", GetLastError());
if (funcAddr)
{
int y = funcAddr(0xabadc0da);
@ -279,40 +279,40 @@ static void test_registerOIDFunction(void)
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG: %ld\n", GetLastError());
"Expected E_INVALIDARG: %d\n", GetLastError());
/* This has no effect, but "succeeds" on XP */
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo",
"1.2.3.4.5.6.7.8.9.10", NULL, NULL);
ok(ret, "Expected pseudo-success, got %ld\n", GetLastError());
ok(ret, "Expected pseudo-success, got %d\n", GetLastError());
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
/* This has no effect */
ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
/* Check with bogus encoding type: */
ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
/* This is written with value 3 verbatim. Thus, the encoding type isn't
* (for now) treated as a mask.
*/
ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
}
static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 };
@ -330,28 +330,28 @@ static void test_registerDefaultOIDFunction(void)
ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* This succeeds on WinXP, although the bogus entry is unusable.
ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, bogusDll);
*/
/* Register one at index 0 */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
/* Reregistering should fail */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
"Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
/* Registering the same one at index 1 should also fail */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
bogusDll);
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
"Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
/* Registering a different one at index 1 succeeds */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
bogus2Dll);
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
sprintf(buf, fmt, 0, func);
rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, buf, &key);
ok(rc == 0, "Expected key to exist, RegOpenKeyW failed: %ld\n", rc);
@ -366,7 +366,7 @@ static void test_registerDefaultOIDFunction(void)
rc = RegQueryValueExW(key, dllW, NULL, &type, (LPBYTE)dllBuf, &size);
ok(rc == 0,
"Expected Dll value to exist, RegQueryValueExW failed: %ld\n", rc);
ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %ld\n", type);
ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %d\n", type);
/* bogusDll was registered first, so that should be first */
ptr = dllBuf;
ok(!lstrcmpiW(ptr, bogusDll), "Unexpected dll\n");
@ -377,17 +377,17 @@ static void test_registerDefaultOIDFunction(void)
/* Unregister both of them */
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogusDll);
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
GetLastError());
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogus2Dll);
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
GetLastError());
/* Now that they're both unregistered, unregistering should fail */
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogusDll);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
/* Repeat a few tests on the normal encoding type */
ret = CryptRegisterDefaultOIDFunction(X509_ASN_ENCODING,
@ -398,7 +398,7 @@ static void test_registerDefaultOIDFunction(void)
ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING,
"CertDllOpenStoreProv", bogusDll);
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());
}
static BOOL WINAPI countOidInfo(PCCRYPT_OID_INFO pInfo, void *pvArg)

View File

@ -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");

File diff suppressed because it is too large Load Diff

View File

@ -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);
}
}