[CRYPT32_WINETEST] Sync crypt32 winetest to wine-10.0 (#8058)

- Sync crypt32 winetest to Wine 10.0.
- Guard tests we can't compile yet.
- Conditionally skip tests that crash on different Windows versions.
This commit is contained in:
Carl J. Bialorucki
2025-08-08 11:28:10 -06:00
committed by GitHub
parent 2cf3f14c50
commit 57092f4990
16 changed files with 7943 additions and 5655 deletions
@@ -25,7 +25,13 @@ add_executable(crypt32_winetest
${SOURCE}
${PCH_SKIP_SOURCE})
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(crypt32_winetest PRIVATE -Wno-format)
endif()
set_module_type(crypt32_winetest win32cui)
add_importlibs(crypt32_winetest crypt32 advapi32 user32 shlwapi shell32 msvcrt kernel32)
add_pch(crypt32_winetest precomp.h "${PCH_SKIP_SOURCE}")
add_rostests_file(TARGET crypt32_winetest)
target_compile_definitions(crypt32_winetest PRIVATE wcsicmp=_wcsicmp)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+169 -212
View File
@@ -77,18 +77,6 @@ static const BYTE signedCRL[] = { 0x30, 0x45, 0x30, 0x2c, 0x30, 0x02, 0x06,
0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c,
0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
static BOOL (WINAPI *pCertFindCertificateInCRL)(PCCERT_CONTEXT,PCCRL_CONTEXT,DWORD,void*,PCRL_ENTRY*);
static PCCRL_CONTEXT (WINAPI *pCertFindCRLInStore)(HCERTSTORE,DWORD,DWORD,DWORD,const void*,PCCRL_CONTEXT);
static BOOL (WINAPI *pCertIsValidCRLForCertificate)(PCCERT_CONTEXT, PCCRL_CONTEXT, DWORD, void*);
static void init_function_pointers(void)
{
HMODULE hdll = GetModuleHandleA("crypt32.dll");
pCertFindCertificateInCRL = (void*)GetProcAddress(hdll, "CertFindCertificateInCRL");
pCertFindCRLInStore = (void*)GetProcAddress(hdll, "CertFindCRLInStore");
pCertIsValidCRLForCertificate = (void*)GetProcAddress(hdll, "CertIsValidCRLForCertificate");
}
static void testCreateCRL(void)
{
PCCRL_CONTEXT context;
@@ -96,11 +84,11 @@ static void testCreateCRL(void)
context = CertCreateCRLContext(0, NULL, 0);
ok(!context && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
context = CertCreateCRLContext(X509_ASN_ENCODING, NULL, 0);
GLE = GetLastError();
ok(!context && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
"Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
ok(!context && GLE == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE);
context = CertCreateCRLContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
ok(!context, "Expected failure\n");
context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
@@ -108,11 +96,11 @@ static void testCreateCRL(void)
ok(!context, "Expected failure\n");
context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL));
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
if (context)
CertFreeCRLContext(context);
context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL));
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
if (context)
CertFreeCRLContext(context);
}
@@ -148,86 +136,80 @@ static void testAddCRL(void)
BOOL ret;
DWORD GLE;
ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
if (!store) return;
/* Bad CRL encoding type */
ret = CertAddEncodedCRLToStore(0, 0, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL), 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL), 0,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* No CRL */
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, NULL, 0, 0, NULL);
GLE = GetLastError();
ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
"Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
ok(!ret && GLE == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE);
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, NULL, 0, 0, NULL);
GLE = GetLastError();
ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
"Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
ok(!ret && GLE == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GLE);
/* Weird--bad add disposition leads to an access violation in Windows.
* Both tests crash on some win9x boxes.
*/
if (0)
{
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
GetLastError() == E_INVALIDARG /* Vista */),
"Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
GetLastError() == E_INVALIDARG /* Vista */),
"Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError());
}
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
GetLastError() == E_INVALIDARG /* Vista */),
"Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), 0, NULL);
ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
GetLastError() == E_INVALIDARG /* Vista */),
"Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError());
/* Weird--can add a CRL to the NULL store (does this have special meaning?)
*/
context = NULL;
ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
if (context)
CertFreeCRLContext(context);
/* Normal cases: a "signed" CRL is okay.. */
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
/* and an unsigned one is too. */
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, CRL, sizeof(CRL),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
sizeof(newerCRL), CERT_STORE_ADD_NEW, NULL);
ok(!ret && GetLastError() == CRYPT_E_EXISTS,
"Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
"Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
/* This should replace (one of) the existing CRL(s). */
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
sizeof(newerCRL), CERT_STORE_ADD_NEWER, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
CertCloseStore(store, 0);
@@ -433,43 +415,37 @@ static void testFindCRL(void)
DWORD count, revoked_count;
BOOL ret;
if (!pCertFindCRLInStore || !pCertFindCertificateInCRL)
{
win_skip("CertFindCRLInStore or CertFindCertificateInCRL not available\n");
return;
}
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
if (!store) return;
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
/* Crashes
context = pCertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL);
context = CertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL);
*/
/* Find any context */
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL);
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
CertFreeCRLContext(context);
/* Bogus flags are ignored */
context = pCertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL);
context = CertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
CertFreeCRLContext(context);
/* CRL encoding type is ignored too */
context = pCertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL);
context = CertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
CertFreeCRLContext(context);
/* This appears to match any cert */
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL);
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
CertFreeCRLContext(context);
@@ -477,28 +453,28 @@ static void testFindCRL(void)
/* Try to match an issuer that isn't in the store */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
sizeof(bigCert2));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
ok(context == NULL, "Expected no matching context\n");
CertFreeCertificateContext(cert);
/* Match an issuer that is in the store */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
CertFreeCRLContext(context);
/* Try various find flags */
context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG,
context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_SIGNATURE_FLAG,
CRL_FIND_ISSUED_BY, cert, NULL);
ok(!context || broken(context != NULL /* Win9x */), "unexpected context\n");
ok(!context, "unexpected context\n");
/* The CRL doesn't have an AKI extension, so it matches any cert */
context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
CRL_FIND_ISSUED_BY, cert, NULL);
ok(context != NULL, "Expected a context\n");
if (context)
@@ -507,22 +483,21 @@ static void testFindCRL(void)
if (0)
{
/* Crash or return NULL/STATUS_ACCESS_VIOLATION */
pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL,
CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR, NULL,
NULL);
pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, NULL);
}
/* Test whether the cert matches the CRL in the store */
issuedForPara.pSubjectCert = cert;
issuedForPara.pIssuerCert = cert;
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, NULL);
ok(context != NULL || broken(!context /* Win9x, NT4 */),
"Expected a context\n");
ok(context != NULL, "Expected a context\n");
if (context)
{
ok(context->cbCrlEncoded == sizeof(signedCRL),
"unexpected CRL size %d\n", context->cbCrlEncoded);
"unexpected CRL size %ld\n", context->cbCrlEncoded);
ok(!memcmp(context->pbCrlEncoded, signedCRL, context->cbCrlEncoded),
"unexpected CRL data\n");
CertFreeCRLContext(context);
@@ -531,27 +506,27 @@ static void testFindCRL(void)
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
v2CRLWithIssuingDistPoint, sizeof(v2CRLWithIssuingDistPoint),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
verisignCRL, sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
issuedForPara.pSubjectCert = cert;
issuedForPara.pIssuerCert = cert;
context = NULL;
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
@@ -560,40 +535,38 @@ static void testFindCRL(void)
* match cert's issuer, but verisignCRL does not, so the expected count
* is 0.
*/
ok(count == 3 || broken(count == 0 /* NT4, Win9x */),
"expected 3 matching CRLs, got %d\n", count);
ok(count == 3, "expected 3 matching CRLs, got %ld\n", count);
/* Only v1CRLWithIssuerAndEntry and v2CRLWithIssuingDistPoint contain
* entries, so the count of CRL entries that match cert is 2.
*/
ok(revoked_count == 2 || broken(revoked_count == 0 /* NT4, Win9x */),
"expected 2 matching CRL entries, got %d\n", revoked_count);
ok(revoked_count == 2, "expected 2 matching CRL entries, got %ld\n", revoked_count);
CertFreeCertificateContext(cert);
/* Try again with a cert that doesn't match any CRLs in the store */
cert = CertCreateCertificateContext(X509_ASN_ENCODING,
bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
issuedForPara.pSubjectCert = cert;
issuedForPara.pIssuerCert = cert;
context = NULL;
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
CertFreeCertificateContext(cert);
@@ -602,28 +575,27 @@ static void testFindCRL(void)
*/
cert = CertCreateCertificateContext(X509_ASN_ENCODING,
verisignCommercialSoftPubCA, sizeof(verisignCommercialSoftPubCA));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
issuedForPara.pIssuerCert = cert;
issuedForPara.pSubjectCert = cert;
context = NULL;
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(cert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 1 || broken(count == 0 /* Win9x, NT4 */),
"expected 1 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
CertFreeCertificateContext(cert);
@@ -649,96 +621,93 @@ static void testFindCRL(void)
context = NULL;
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_FOR,
&issuedForPara, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 1 || broken(count == 0 /* Win9x, NT4 */),
"expected 1 matching CRLs, got %d\n", count);
ok(revoked_count == 1 || broken(revoked_count == 0 /* Win9x, NT4 */),
"expected 1 matching CRL entries, got %d\n", revoked_count);
ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n", revoked_count);
/* Test CRL_FIND_ISSUED_BY flags */
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY,
endCert, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY,
context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY,
rootCert, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 1, "expected 1 matching CRLs, got %d\n", count);
ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n",
ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n",
revoked_count);
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
CRL_FIND_ISSUED_BY, endCert, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
context = CertFindCRLInStore(store, 0, CRL_FIND_ISSUED_BY_AKI_FLAG,
CRL_FIND_ISSUED_BY, rootCert, context);
if (context)
{
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(rootCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 0 || broken(count == 1 /* Win9x */),
"expected 0 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0,
context = CertFindCRLInStore(store, 0,
CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, endCert,
context);
if (context)
@@ -746,17 +715,17 @@ static void testFindCRL(void)
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
revoked_count);
count = revoked_count = 0;
do {
context = pCertFindCRLInStore(store, 0,
context = CertFindCRLInStore(store, 0,
CRL_FIND_ISSUED_BY_SIGNATURE_FLAG, CRL_FIND_ISSUED_BY, rootCert,
context);
if (context)
@@ -764,13 +733,13 @@ static void testFindCRL(void)
PCRL_ENTRY entry;
count++;
if (pCertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
if (CertFindCertificateInCRL(endCert, context, 0, NULL, &entry) &&
entry)
revoked_count++;
}
} while (context);
ok(count == 1, "expected 1 matching CRLs, got %d\n", count);
ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n",
ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n",
revoked_count);
CertFreeCertificateContext(rootCert);
CertFreeCertificateContext(endCert);
@@ -787,7 +756,7 @@ static void testGetCRLFromStore(void)
DWORD flags;
BOOL ret;
ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
if (!store) return;
/* Crash
@@ -799,17 +768,17 @@ static void testGetCRLFromStore(void)
flags = 0xffffffff;
context = CertGetCRLFromStore(store, NULL, NULL, &flags);
ok(!context && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* Test an empty store */
flags = 0;
context = CertGetCRLFromStore(store, NULL, NULL, &flags);
ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
/* NULL matches any CRL */
flags = 0;
@@ -820,17 +789,17 @@ static void testGetCRLFromStore(void)
/* This cert's issuer isn't in */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
sizeof(bigCert2));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
context = CertGetCRLFromStore(store, cert, NULL, &flags);
ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
CertFreeCertificateContext(cert);
/* But this one is */
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
context = CertGetCRLFromStore(store, cert, NULL, &flags);
ok(context != NULL, "Expected a context\n");
@@ -851,10 +820,10 @@ static void checkCRLHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
memset(hashProperty, 0, sizeof(hashProperty));
size = sizeof(hash);
ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
ret = CertGetCRLContextProperty(context, propID, hashProperty, &size);
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n",
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n",
propID);
}
@@ -863,7 +832,7 @@ static void testCRLProperties(void)
PCCRL_CONTEXT context = CertCreateCRLContext(X509_ASN_ENCODING,
CRL, sizeof(CRL));
ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
if (context)
{
DWORD propID, numProps, access, size;
@@ -882,12 +851,12 @@ static void testCRLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
/* Tests with a NULL cert context. Prop ID 0 fails.. */
ret = CertSetCRLContextProperty(NULL, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* while this just crashes.
ret = CertSetCRLContextProperty(NULL, CERT_KEY_PROV_HANDLE_PROP_ID, 0,
NULL);
@@ -895,7 +864,7 @@ static void testCRLProperties(void)
ret = CertSetCRLContextProperty(context, 0, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* Can't set the cert property directly, this crashes.
ret = CertSetCRLContextProperty(context, CERT_CRL_PROP_ID, 0, CRL);
*/
@@ -912,14 +881,14 @@ static void testCRLProperties(void)
ret = CertGetCRLContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID,
NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
/* And, an implicit property */
ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
NULL, &size);
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
&access, &size);
ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
"Didn't expect a persisted crl\n");
/* Trying to set this "read only" property crashes.
@@ -932,16 +901,16 @@ static void testCRLProperties(void)
blob.pbData = hash;
blob.cbData = sizeof(hash);
ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, &blob);
ok(ret, "CertSetCRLContextProperty failed: %08x\n",
ok(ret, "CertSetCRLContextProperty failed: %08lx\n",
GetLastError());
size = sizeof(hashProperty);
ret = CertGetCRLContextProperty(context, CERT_HASH_PROP_ID,
hashProperty, &size);
ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError());
ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
/* Delete the (bogus) hash, and get the real one */
ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, NULL);
ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError());
checkCRLHash(CRL, sizeof(CRL), CALG_SHA1, context, CERT_HASH_PROP_ID);
/* Now that the hash property is set, we should get one property when
@@ -954,7 +923,7 @@ static void testCRLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
/* Check a few other implicit properties */
checkCRLHash(CRL, sizeof(CRL), CALG_MD5, context,
@@ -985,14 +954,12 @@ static void testIsValidCRLForCert(void)
PCCRL_CONTEXT crl;
HCERTSTORE store;
if(!pCertIsValidCRLForCertificate) return;
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
sizeof(v1CRLWithIssuerAndEntry));
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert1 != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert1 != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
/* Crash
@@ -1001,24 +968,24 @@ static void testIsValidCRLForCert(void)
*/
/* Curiously, any CRL is valid for the NULL certificate */
ret = pCertIsValidCRLForCertificate(NULL, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(NULL, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
/* Same issuer for both cert and CRL, this CRL is valid for that cert */
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
cert2 = CertCreateCertificateContext(X509_ASN_ENCODING,
bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer));
ok(cert2 != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert2 != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
/* Yet more curious: different issuers for these, yet the CRL is valid for
* that cert. According to MSDN, the relevant bit to check is whether the
* CRL has a CRL_ISSUING_DIST_POINT extension.
*/
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl);
@@ -1027,38 +994,38 @@ static void testIsValidCRLForCert(void)
*/
crl = CertCreateCRLContext(X509_ASN_ENCODING, v2CRLWithIssuingDistPoint,
sizeof(v2CRLWithIssuingDistPoint));
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
"expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
"expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
"expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
"expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
/* With a CRL_ISSUING_DIST_POINT in the CRL, it matches the cert containing
* a CRL_DIST_POINTS_INFO extension.
*/
cert3 = CertCreateCertificateContext(X509_ASN_ENCODING,
bigCertWithCRLDistPoints, sizeof(bigCertWithCRLDistPoints));
ok(cert3 != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert3 != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl);
/* And again, with a real CRL, the CRL is valid for all three certs. */
crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL));
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl);
@@ -1067,18 +1034,18 @@ static void testIsValidCRLForCert(void)
*/
store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, &crl);
ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert1, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert2, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
ret = CertIsValidCRLForCertificate(cert3, crl, 0, NULL);
ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl);
@@ -1103,46 +1070,40 @@ static void testFindCertInCRL(void)
PCCRL_CONTEXT crl;
PCRL_ENTRY entry;
if (!pCertFindCertificateInCRL)
{
win_skip("CertFindCertificateInCRL() is not available\n");
return;
}
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
/* Crash
ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL);
ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, NULL);
ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, NULL);
ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, NULL);
ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry);
ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, &entry);
ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, &entry);
ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL);
ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, NULL);
ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, NULL);
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, NULL);
ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry);
ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, &entry);
ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, &entry);
*/
crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
sizeof(verisignCRL));
ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(entry == NULL, "Expected not to find an entry in CRL\n");
CertFreeCRLContext(crl);
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
sizeof(v1CRLWithIssuerAndEntry));
ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(entry != NULL, "Expected to find an entry in CRL\n");
CertFreeCRLContext(crl);
/* Entry found even though CRL issuer doesn't match cert issuer */
crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer,
sizeof(crlWithDifferentIssuer));
ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
ok(entry != NULL, "Expected to find an entry in CRL\n");
CertFreeCRLContext(crl);
@@ -1156,18 +1117,18 @@ static void testVerifyCRLRevocation(void)
PCCRL_CONTEXT crl;
ret = CertVerifyCRLRevocation(0, NULL, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, NULL, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert));
/* Check against no CRL */
ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 0, NULL);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
/* Check against CRL with entry for the cert */
crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
@@ -1183,7 +1144,7 @@ static void testVerifyCRLRevocation(void)
/* Check against CRL with different issuer and entry for the cert */
crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer,
sizeof(crlWithDifferentIssuer));
ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(!ret, "CertVerifyCRLRevocation should have been revoked\n");
@@ -1194,10 +1155,10 @@ static void testVerifyCRLRevocation(void)
sizeof(verisignCRL));
ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
(PCRL_INFO *)&crl->pCrlInfo);
ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
CertFreeCRLContext(crl);
CertFreeCertificateContext(cert);
@@ -1205,16 +1166,12 @@ static void testVerifyCRLRevocation(void)
START_TEST(crl)
{
init_function_pointers();
testCreateCRL();
testDupCRL();
testAddCRL();
testFindCRL();
testGetCRLFromStore();
testCRLProperties();
testIsValidCRLForCert();
testFindCertInCRL();
testVerifyCRLRevocation();
+34 -60
View File
@@ -114,57 +114,44 @@ static void testCreateCTL(void)
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(0, NULL, 0);
ok(!ctl && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(X509_ASN_ENCODING, NULL, 0);
ok(!ctl &&
(GetLastError() == ERROR_INVALID_DATA ||
GetLastError() == OSS_MORE_INPUT), /* win9x */
"expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
ok(!ctl && GetLastError() == ERROR_INVALID_DATA,
"expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
GetLastError());
/* An empty CTL can't be created.. */
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(X509_ASN_ENCODING, emptyCTL, sizeof(emptyCTL));
ok(!ctl &&
(GetLastError() == ERROR_INVALID_DATA ||
GetLastError() == OSS_DATA_ERROR), /* win9x */
"expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
ok(!ctl && GetLastError() == ERROR_INVALID_DATA,
"expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
GetLastError());
/* Nor can any of these "signed" CTLs whose inner content OID isn't
* szOID_CTL.
*/
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(X509_ASN_ENCODING, signedCTL, sizeof(signedCTL));
ok(!ctl &&
(GetLastError() == ERROR_INVALID_DATA ||
GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
GetLastError() == ERROR_SUCCESS /* some win98 */),
"expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(),
ok(!ctl && GetLastError() == ERROR_INVALID_DATA,
"expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n",
GetLastError(),
GetLastError());
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(X509_ASN_ENCODING, ctlWithOneEntry,
sizeof(ctlWithOneEntry));
ok(!ctl &&
(GetLastError() == ERROR_INVALID_DATA ||
GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
GetLastError() == OSS_DATA_ERROR /* some win98 */ ||
GetLastError() == ERROR_SUCCESS /* some win98 */),
"expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, OSS_DATA_ERROR, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(),
ok(!ctl && GetLastError() == ERROR_INVALID_DATA,
"expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
GetLastError());
SetLastError(0xdeadbeef);
ctl = CertCreateCTLContext(X509_ASN_ENCODING,
signedCTLWithSubjectAlgorithm, sizeof(signedCTLWithSubjectAlgorithm));
ok(!ctl &&
(GetLastError() == ERROR_INVALID_DATA ||
GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
GetLastError() == ERROR_SUCCESS /* some win98 */),
"expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
ok(!ctl && GetLastError() == ERROR_INVALID_DATA,
"expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
GetLastError());
/* This signed CTL with the appropriate inner content type can be decoded.
*/
ctl = CertCreateCTLContext(X509_ASN_ENCODING,
signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent));
ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError());
ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError());
if (ctl)
{
/* Even though the CTL was decoded with X509_ASN_ENCODING, the
@@ -172,7 +159,7 @@ static void testCreateCTL(void)
*/
ok(ctl->dwMsgAndCertEncodingType ==
(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING),
"expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08x\n",
"expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08lx\n",
ctl->dwMsgAndCertEncodingType);
CertFreeCTLContext(ctl);
}
@@ -182,7 +169,7 @@ static void testCreateCTL(void)
ctl = CertCreateCTLContext(X509_ASN_ENCODING,
signedCTLWithCTLInnerContentAndBadSig,
sizeof(signedCTLWithCTLInnerContentAndBadSig));
ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError());
ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError());
if (ctl)
CertFreeCTLContext(ctl);
}
@@ -221,12 +208,12 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
memset(hashProperty, 0, sizeof(hashProperty));
size = sizeof(hash);
ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
ret = CertGetCTLContextProperty(context, propID, hashProperty, &size);
ok(ret, "CertGetCTLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
if (ret)
ok(!memcmp(hash, hashProperty, size),
"Unexpected hash for property %d\n", propID);
"Unexpected hash for property %ld\n", propID);
}
static void testCTLProperties(void)
@@ -237,11 +224,6 @@ static void testCTLProperties(void)
ctl = CertCreateCTLContext(X509_ASN_ENCODING,
signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent));
if (!ctl)
{
skip("CertCreateCTLContext failed: %08x\n", GetLastError());
return;
}
/* No properties as yet */
propID = 0;
@@ -251,17 +233,15 @@ static void testCTLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
/* An implicit property */
ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, NULL,
&size);
ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */),
"CertGetCTLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, &access,
&size);
ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */),
"CertGetCTLContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
if (ret)
ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
"Didn't expect a persisted cert\n");
@@ -279,7 +259,7 @@ static void testCTLProperties(void)
if (propID)
numProps++;
} while (propID != 0);
ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
checkHash(signedCTLWithCTLInnerContent,
sizeof(signedCTLWithCTLInnerContent), CALG_MD5, ctl,
@@ -360,12 +340,12 @@ static void testAddCTLToStore(void)
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithCTLInnerContentAndBadSig,
sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_ALWAYS,
NULL);
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
/* Check that two exist */
numCTLs = 0;
ctl = NULL;
@@ -374,7 +354,7 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs);
CertCloseStore(store, 0);
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -383,15 +363,15 @@ static void testAddCTLToStore(void)
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
CERT_STORE_ADD_NEW, NULL);
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
/* so adding the second CTL fails. */
SetLastError(0xdeadbeef);
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithCTLInnerContentAndBadSig,
sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_NEW,
NULL);
ok(!ret && (GetLastError() == CRYPT_E_EXISTS || GetLastError() == OSS_DATA_ERROR),
"expected CRYPT_E_EXISTS or OSS_DATA_ERROR, got %d %08x\n", ret, GetLastError());
ok(!ret && GetLastError() == CRYPT_E_EXISTS,
"expected CRYPT_E_EXISTS, got %d %08lx\n", ret, GetLastError());
CertCloseStore(store, 0);
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -402,13 +382,12 @@ static void testAddCTLToStore(void)
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
CERT_STORE_ADD_NEW, NULL);
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
expectedCTLs = 1;
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithUsage, sizeof(signedCTLWithUsage), CERT_STORE_ADD_NEW,
NULL);
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* some win98 */),
"CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
if (ret)
expectedCTLs++;
/* Check that two exist */
@@ -419,7 +398,7 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
ok(numCTLs == expectedCTLs, "expected %d CTLs, got %d\n", expectedCTLs,
ok(numCTLs == expectedCTLs, "expected %ld CTLs, got %ld\n", expectedCTLs,
numCTLs);
CertCloseStore(store, 0);
@@ -431,16 +410,11 @@ static void testAddCTLToStore(void)
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithListID1, sizeof(signedCTLWithListID1), CERT_STORE_ADD_NEW,
NULL);
if (!ret)
{
skip("adding a CTL with an empty usage not supported\n");
return;
}
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
signedCTLWithListID2, sizeof(signedCTLWithListID2), CERT_STORE_ADD_NEW,
NULL);
ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
/* Check that two exist */
numCTLs = 0;
ctl = NULL;
@@ -449,7 +423,7 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs);
CertCloseStore(store, 0);
}
File diff suppressed because it is too large Load Diff
+97 -132
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 %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
if (0)
{
@@ -54,25 +54,25 @@ static void test_findAttribute(void)
SetLastError(0xdeadbeef);
ret = CertFindAttribute(NULL, 1, &attr);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
GetLastError());
}
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("bogus", 1, &attr);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("1.2.4", 1, &attr);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindAttribute("1.2.3", 1, &attr);
ok(ret != NULL, "CertFindAttribute failed: %08x\n", GetLastError());
ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError());
}
static void test_findExtension(void)
@@ -86,7 +86,7 @@ static void test_findExtension(void)
SetLastError(0xdeadbeef);
ret = CertFindExtension(NULL, 0, NULL);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
if (0)
{
@@ -99,25 +99,25 @@ static void test_findExtension(void)
SetLastError(0xdeadbeef);
ret = CertFindExtension(NULL, 1, &ext);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
GetLastError());
}
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("bogus", 1, &ext);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("1.2.4", 1, &ext);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindExtension("1.2.3", 1, &ext);
ok(ret != NULL, "CertFindExtension failed: %08x\n", GetLastError());
ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError());
}
static void test_findRDNAttr(void)
@@ -142,25 +142,25 @@ static void test_findRDNAttr(void)
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr(NULL, &nameInfo);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
"Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
GetLastError());
}
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("bogus", &nameInfo);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* returns NULL, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("1.2.4", &nameInfo);
ok(ret == NULL, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
GetLastError());
/* succeeds, last error not set */
SetLastError(0xdeadbeef);
ret = CertFindRDNAttr("1.2.3", &nameInfo);
ok(ret != NULL, "CertFindRDNAttr failed: %08x\n", GetLastError());
ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError());
}
static void test_verifyTimeValidity(void)
@@ -178,16 +178,16 @@ static void test_verifyTimeValidity(void)
*/
/* Check with 0 NotBefore and NotAfter */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 1, "Expected 1, got %d\n", ret);
ok(ret == 1, "Expected 1, got %ld\n", ret);
info.NotAfter = fileTime;
/* Check with NotAfter equal to comparison time */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 0, "Expected 0, got %d\n", ret);
ok(ret == 0, "Expected 0, got %ld\n", ret);
/* Check with NotBefore after comparison time */
info.NotBefore = fileTime;
info.NotBefore.dwLowDateTime += 5000;
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == -1, "Expected -1, got %d\n", ret);
ok(ret == -1, "Expected -1, got %ld\n", ret);
}
static void test_cryptAllocate(void)
@@ -195,12 +195,12 @@ static void test_cryptAllocate(void)
LPVOID buf;
buf = CryptMemAlloc(0);
ok(buf != NULL, "CryptMemAlloc failed: %08x\n", GetLastError());
ok(buf != NULL, "CryptMemAlloc failed: %08lx\n", GetLastError());
CryptMemFree(buf);
/* CryptMemRealloc(NULL, 0) fails pre-Vista */
buf = CryptMemAlloc(0);
buf = CryptMemRealloc(buf, 1);
ok(buf != NULL, "CryptMemRealloc failed: %08x\n", GetLastError());
ok(buf != NULL, "CryptMemRealloc failed: %08lx\n", GetLastError());
CryptMemFree(buf);
}
@@ -223,7 +223,7 @@ static void test_cryptTls(void)
/* One normal pass */
index = pI_CryptAllocTls();
ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
if (index)
{
LPVOID ptr;
@@ -231,22 +231,22 @@ static void test_cryptTls(void)
ptr = pI_CryptGetTls(index);
ok(!ptr, "Expected NULL\n");
ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
ptr = pI_CryptGetTls(index);
ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
/* This crashes
ret = pI_CryptFreeTls(index, 1);
*/
ret = pI_CryptFreeTls(index, 0);
ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
ok(ret, "I_CryptFreeTls failed: %08lx\n", GetLastError());
ret = pI_CryptFreeTls(index, 0);
ok(!ret, "I_CryptFreeTls succeeded\n");
ok(GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
}
/* Similar pass, check I_CryptDetachTls */
index = pI_CryptAllocTls();
ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
if (index)
{
LPVOID ptr;
@@ -254,7 +254,7 @@ static void test_cryptTls(void)
ptr = pI_CryptGetTls(index);
ok(!ptr, "Expected NULL\n");
ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
ptr = pI_CryptGetTls(index);
ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
ptr = pI_CryptDetachTls(index);
@@ -272,34 +272,26 @@ static void test_readTrustedPublisherDWORD(void)
pReadDWORD = (void *)GetProcAddress(hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry");
if (pReadDWORD)
{
static const WCHAR safer[] = {
'S','o','f','t','w','a','r','e','\\',
'P','o','l','i','c','i','e','s','\\',
'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
'C','e','r','t','i','f','i','c','a','t','e','s','\\',
'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',
'\\','S','a','f','e','r',0 };
static const WCHAR authenticodeFlags[] = { 'A','u','t','h','e','n',
't','i','c','o','d','e','F','l','a','g','s',0 };
BOOL ret, exists = FALSE;
DWORD size, readFlags = 0, returnedFlags;
HKEY key;
LONG rc;
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, safer, &key);
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,
L"Software\\Policies\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer", &key);
if (rc == ERROR_SUCCESS)
{
size = sizeof(readFlags);
rc = RegQueryValueExW(key, authenticodeFlags, NULL, NULL,
rc = RegQueryValueExW(key, L"AuthenticodeFlags", NULL, NULL,
(LPBYTE)&readFlags, &size);
if (rc == ERROR_SUCCESS)
exists = TRUE;
}
returnedFlags = 0xdeadbeef;
ret = pReadDWORD(authenticodeFlags, &returnedFlags);
ret = pReadDWORD(L"AuthenticodeFlags", &returnedFlags);
ok(ret == exists, "Unexpected return value\n");
ok(readFlags == returnedFlags,
"Expected flags %08x, got %08x\n", readFlags, returnedFlags);
"Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
}
}
@@ -337,28 +329,28 @@ static void test_getDefaultCryptProv(void)
prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(1);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(0);
ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError());
ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError());
CryptReleaseContext(prov, 0);
for (i = 0; i < ARRAY_SIZE(test_prov); i++)
{
if (winetest_debug > 1)
trace("%u: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
trace("%lu: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
GET_ALG_CLASS(test_prov[i].algid) >> 13, GET_ALG_TYPE(test_prov[i].algid) >> 9, GET_ALG_SID(test_prov[i].algid));
prov = pI_CryptGetDefaultCryptProv(test_prov[i].algid);
if (!prov)
{
todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_NO_SIGN)
ok(test_prov[i].optional, "%u: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_NO_SIGN)
ok(test_prov[i].optional, "%lu: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
continue;
}
@@ -367,9 +359,9 @@ todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_N
{
name = CryptMemAlloc(size);
ret = CryptGetProvParam(prov, PP_NAME, (BYTE *)name, &size, 0);
ok(ret, "%u: CryptGetProvParam failed %#x\n", i, GetLastError());
ok(ret, "%lu: CryptGetProvParam failed %#lx\n", i, GetLastError());
if (winetest_debug > 1)
trace("%u: algid %#x, name %s\n", i, test_prov[i].algid, name);
trace("%lu: algid %#x, name %s\n", i, test_prov[i].algid, name);
CryptMemFree(name);
}
@@ -393,119 +385,92 @@ static void test_CryptInstallOssGlobal(void)
}
}
static const BYTE encodedInt[] = { 0x02,0x01,0x01 };
static const WCHAR encodedIntStr[] = { '0','2',' ','0','1',' ','0','1',0 };
static const BYTE encodedBigInt[] = { 0x02,0x1f,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,
0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f };
static const WCHAR encodedBigIntStr[] = { '0','2',' ','1','f',' ','0','1',' ',
'0','2',' ','0','3',' ','0','4',' ','0','5',' ','0','6',' ','0','7',' ','0',
'8',' ','0','9',' ','0','a',' ','0','b',' ','0','c',' ','0','d',' ','0','e',
' ','0','f',' ','1','0',' ','1','1',' ','1','2',' ','1','3',' ','1','4',' ',
'1','5',' ','1','6',' ','1','7',' ','1','8',' ','1','9',' ','1','a',' ','1',
'b',' ','1','c',' ','1','d',' ','1','e',' ','1','f',0 };
static void test_format_object(void)
{
BOOL (WINAPI *pCryptFormatObject)(DWORD dwEncoding, DWORD dwFormatType,
DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
const BYTE *pbEncoded, DWORD dwEncoded, void *pbFormat,
DWORD *pcbFormat);
static const BYTE encodedInt[] = {0x02,0x01,0x01};
static const BYTE encodedBigInt[] = {0x02,0x1f,0x01,0x02,0x03,0x04,0x05,
0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f};
static const WCHAR encodedBigIntStr[] = L"02 1f 01 02 03 04 05 06 07 08 09 "
"0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f";
BOOL ret;
DWORD size;
LPWSTR str;
WCHAR str[100];
pCryptFormatObject = (void *)GetProcAddress(hCrypt, "CryptFormatObject");
if (!pCryptFormatObject)
{
skip("No CryptFormatObject\n");
return;
}
/* Crash */
if (0)
{
pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL);
CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL);
}
/* When called with any but the default encoding, it fails to find a
* formatting function.
*/
SetLastError(0xdeadbeef);
ret = pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
ret = CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
/* When called with the default encoding type for any undefined struct type
* (including none), it succeeds: the default encoding is a hex string
* encoding.
*/
SetLastError(0xdeadbeef);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
NULL, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
if (ret)
{
if (size == 0 && GetLastError() == ERROR_FILE_NOT_FOUND)
{
win_skip("CryptFormatObject has no default implementation\n");
return;
}
ok(size == sizeof(WCHAR), "unexpected size %d\n", size);
str = HeapAlloc(GetProcessHeap(), 0, size);
SetLastError(0xdeadbeef);
size = 0;
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
str, &size);
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"expected ERROR_MORE_DATA, got %d\n", GetLastError());
size = sizeof(WCHAR);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
str, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
ok(!str[0], "expected empty string\n");
HeapFree(GetProcessHeap(), 0, str);
}
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
sizeof(encodedInt), NULL, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
if (ret)
{
str = HeapAlloc(GetProcessHeap(), 0, size);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
encodedInt, sizeof(encodedInt), str, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
ok(!lstrcmpW(str, encodedIntStr), "unexpected format string\n");
HeapFree(GetProcessHeap(), 0, str);
}
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
encodedBigInt, sizeof(encodedBigInt), NULL, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
if (ret)
{
str = HeapAlloc(GetProcessHeap(), 0, size);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
encodedBigInt, sizeof(encodedBigInt), str, &size);
ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
ok(!lstrcmpiW(str, encodedBigIntStr), "unexpected format string\n");
HeapFree(GetProcessHeap(), 0, str);
}
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
ok(size == sizeof(WCHAR) || broken(!size) /* Win10 1709+ */, "wrong size %ld\n", size);
SetLastError(0xdeadbeef);
size = 0;
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_MORE_DATA, "wrong error %lu\n", GetLastError());
size = sizeof(WCHAR);
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size);
ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
ok(!str[0], "expected empty string\n");
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
sizeof(encodedInt), NULL, &size);
ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
ok(size >= sizeof(L"02 01 01"), "wrong size %lu\n", size);
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
sizeof(encodedInt), str, &size);
ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
ok(!wcscmp(str, L"02 01 01"), "wrong string %s\n", wine_dbgstr_w(str));
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedBigInt,
sizeof(encodedBigInt), NULL, &size);
ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
ok(size >= sizeof(encodedBigIntStr), "wrong size %lu\n", size);
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
encodedBigInt, sizeof(encodedBigInt), str, &size);
ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
ok(!wcsicmp(str, encodedBigIntStr), "wrong string %s\n", wine_dbgstr_w(str));
/* When called with the default encoding type for any undefined struct
* type but CRYPT_FORMAT_STR_NO_HEX specified, it fails to find a
* formatting function.
*/
SetLastError(0xdeadbeef);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, CRYPT_FORMAT_STR_NO_HEX,
NULL, NULL, NULL, 0, NULL, &size);
ret = CryptFormatObject(X509_ASN_ENCODING, 0, CRYPT_FORMAT_STR_NO_HEX,
NULL, NULL, NULL, 0, NULL, &size);
ok(!ret, "CryptFormatObject succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
"expected ERROR_FILE_NOT_FOUND or no change, got %d\n", GetLastError());
ok(GetLastError() == ERROR_FILE_NOT_FOUND
|| GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
"wrong error %lu\n", GetLastError());
/* When called to format an AUTHORITY_KEY_ID2_INFO, it fails when no
* data are given.
*/
SetLastError(0xdeadbeef);
ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL,
szOID_AUTHORITY_KEY_IDENTIFIER2, NULL, 0, NULL, &size);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %d\n", GetLastError());
ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL,
szOID_AUTHORITY_KEY_IDENTIFIER2, NULL, 0, NULL, &size);
ok(!ret, "expected failure\n");
ok(GetLastError() == E_INVALIDARG, "wrong error %lu\n", GetLastError());
}
START_TEST(main)
+162 -228
View File
@@ -27,23 +27,6 @@
#include "wine/test.h"
static BOOL (WINAPI * pCryptAcquireContextA)
(HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD);
static void init_function_pointers(void)
{
HMODULE hAdvapi32 = GetModuleHandleA("advapi32.dll");
#define GET_PROC(dll, func) \
p ## func = (void *)GetProcAddress(dll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GET_PROC(hAdvapi32, CryptAcquireContextA)
#undef GET_PROC
}
static const BYTE dataEmptyBareContent[] = { 0x04,0x00 };
static const BYTE dataEmptyContent[] = {
0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x02,
@@ -70,40 +53,35 @@ static void test_msg_get_signer_count(void)
SetLastError(0xdeadbeef);
count = CryptGetMessageSignerCount(0, NULL, 0);
ok(count == -1, "Expected -1, got %d\n", count);
ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n",
ok(count == -1, "Expected -1, got %ld\n", count);
ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n",
GetLastError());
SetLastError(0xdeadbeef);
count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, NULL, 0);
ok(count == -1, "Expected -1, got %d\n", count);
ok(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG, /* win9x */
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(count == -1, "Expected -1, got %ld\n", count);
ok(GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
dataEmptyBareContent, sizeof(dataEmptyBareContent));
ok(count == -1, "Expected -1, got %d\n", count);
ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH, /* win9x */
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(count == -1, "Expected -1, got %ld\n", count);
ok(GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
dataEmptyContent, sizeof(dataEmptyContent));
ok(count == -1, "Expected -1, got %d\n", count);
ok(count == -1, "Expected -1, got %ld\n", count);
ok(GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
signedEmptyBareContent, sizeof(signedEmptyBareContent));
ok(count == -1, "Expected -1, got %d\n", count);
ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_DATA_ERROR, /* win9x */
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(count == -1, "Expected -1, got %ld\n", count);
ok(GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
signedEmptyContent, sizeof(signedEmptyContent));
ok(count == 1 ||
broken(count == -1), /* win9x */
"Expected 1, got %d\n", count);
ok(count == 1, "Expected 1, got %ld\n", count);
}
static BYTE detachedHashContent[] = {
@@ -132,46 +110,42 @@ static void test_verify_detached_message_hash(void)
ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = sizeof(para);
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG), /* win9x */
"expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
para.dwMsgEncodingType = X509_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG), /* win9x */
"expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
/* Curiously, passing no data to hash succeeds.. */
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 0, NULL, NULL, NULL, NULL);
todo_wine
ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
/* as does passing the actual content of the message to hash.. */
size = sizeof(msgData);
pMsgData = msgData;
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL);
ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
/* while passing data to hash that isn't the content of the message fails.
*/
size = sizeof(detachedHashContent);
@@ -180,7 +154,7 @@ static void test_verify_detached_message_hash(void)
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
"expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
"expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError());
/* Getting the size of the hash while passing no hash data causes the
* hash to be checked (and fail.)
*/
@@ -188,23 +162,23 @@ static void test_verify_detached_message_hash(void)
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 0, NULL, NULL, NULL, &hashSize);
ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
"expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
"expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError());
size = sizeof(msgData);
pMsgData = msgData;
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, &hashSize);
ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
ok(hashSize == sizeof(hash), "unexpected size %d\n", hashSize);
ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
ok(hashSize == sizeof(hash), "unexpected size %ld\n", hashSize);
hashSize = 1;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize);
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"expected ERROR_MORE_DATA, got %08x\n", GetLastError());
"expected ERROR_MORE_DATA, got %08lx\n", GetLastError());
hashSize = sizeof(hash);
ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize);
ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
}
static BYTE hashContent[] = {
@@ -228,31 +202,30 @@ static void test_verify_message_hash(void)
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = sizeof(para);
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG, /* win98 */
"Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
/* Verifying the hash of a detached message succeeds? */
ret = CryptVerifyMessageHash(&para, detachedHashContent,
sizeof(detachedHashContent), NULL, NULL, NULL, NULL);
todo_wine
ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
/* As does verifying the hash of a regular message. */
ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
NULL, NULL, NULL, NULL);
ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
NULL, &size, NULL, NULL);
ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
if (ret)
buf = CryptMemAlloc(size);
if (buf)
@@ -261,11 +234,11 @@ static void test_verify_message_hash(void)
ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
buf, &size, NULL, NULL);
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"expected ERROR_MORE_DATA, got %08x\n", GetLastError());
"expected ERROR_MORE_DATA, got %08lx\n", GetLastError());
ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
buf, &size, NULL, NULL);
ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
ok(size == sizeof(msgData), "unexpected size %d\n", size);
ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
ok(size == sizeof(msgData), "unexpected size %ld\n", size);
ok(!memcmp(buf, msgData, size), "unexpected value\n");
CryptMemFree(buf);
}
@@ -355,32 +328,31 @@ static void test_verify_detached_message_signature(void)
ret = CryptVerifyDetachedMessageSignature(NULL, 0, NULL, 0, 0, NULL,
NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = sizeof(para);
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.dwMsgAndCertEncodingType = X509_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG, /* win98 */
"Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
/* None of these messages contains a cert in the message itself, so the
* default callback isn't able to verify their signature.
*/
@@ -389,39 +361,33 @@ static void test_verify_detached_message_signature(void)
sizeof(signedWithCertContent), 0, NULL, NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
todo_wine
ok(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR, /* win98 */
"Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, signedContent,
sizeof(signedContent), 0, NULL, NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR, /* win98 */
"Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
sizeof(detachedSignedContent), 0, NULL, NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR, /* win98 */
"Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
pContent = msgData;
cbContent = sizeof(msgData);
ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR, /* win98 */
"Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
/* Passing the correct callback results in success */
para.pfnGetSignerCertificate = msg_get_signer_callback;
ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL);
ok(ret ||
broken(!ret), /* win98 */
"CryptVerifyDetachedMessageSignature failed: %08x\n",
ok(ret, "CryptVerifyDetachedMessageSignature failed: %08lx\n",
GetLastError());
/* Not passing the correct data to be signed results in the signature not
* matching.
@@ -430,9 +396,8 @@ static void test_verify_detached_message_signature(void)
ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
sizeof(detachedSignedContent), 0, NULL, NULL, NULL);
ok(!ret, "Expected 0, got %d\n", ret);
ok(GetLastError() == NTE_BAD_SIGNATURE ||
GetLastError() == OSS_DATA_ERROR, /* win98 */
"Expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n", GetLastError());
ok(GetLastError() == NTE_BAD_SIGNATURE,
"Expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError());
}
static const BYTE signedWithCertEmptyContent[] = {
@@ -510,86 +475,74 @@ static void test_verify_message_signature(void)
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* Is cbDecoded set when invalid parameters are passed? */
cbDecoded = 0xdeadbeef;
ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, &cbDecoded,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
ok(cbDecoded == 0, "expected 0, got %08x\n", cbDecoded);
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
ok(cbDecoded == 0, "expected 0, got %08lx\n", cbDecoded);
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = sizeof(para);
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = 0;
para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
para.cbSize = sizeof(para);
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG), /* win9x */
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
/* Check whether cert is set on error */
cert = (PCCERT_CONTEXT)0xdeadbeef;
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, &cert);
ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG /* NT40 */),
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
ok(cert == NULL, "Expected NULL cert\n");
/* Check whether cbDecoded is set on error */
cbDecoded = 0xdeadbeef;
ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, &cbDecoded,
NULL);
ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_BAD_ARG /* NT40 */),
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
ok(!cbDecoded, "Expected 0\n");
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, dataEmptyBareContent,
sizeof(dataEmptyBareContent), NULL, 0, NULL);
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* NT40 */),
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH, /* win9x */
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
ok(GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, dataEmptyContent,
sizeof(dataEmptyContent), NULL, 0, NULL);
ok(!ret && GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE,
"Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08x\n", GetLastError());
"Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, signedEmptyBareContent,
sizeof(signedEmptyBareContent), NULL, 0, NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_DATA_ERROR), /* win9x */
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, signedEmptyContent,
sizeof(signedEmptyContent), NULL, 0, NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR), /* win9x */
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptVerifyMessageSignature(&para, 0, signedContent,
sizeof(signedContent), NULL, 0, NULL);
ok(!ret &&
(GetLastError() == CRYPT_E_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR), /* win9x */
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
/* FIXME: Windows fails with CRYPT_E_NOT_FOUND for these messages, but
* their signer certs have invalid public keys that fail to decode. In
* Wine therefore the failure is an ASN error. Need some messages with
@@ -616,22 +569,22 @@ static void test_verify_message_signature(void)
ret = CryptVerifyMessageSignature(&para, 0,
signedWithCertWithValidPubKeyContent,
sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL);
ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError());
ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded);
ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError());
ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded);
cbDecoded = 0;
ret = CryptVerifyMessageSignature(&para, 0,
signedWithCertWithValidPubKeyContent,
sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL);
/* Setting cbDecoded to 0 succeeds when a NULL buffer is provided */
ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError());
ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded);
ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError());
ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded);
cbDecoded = 0;
ret = CryptVerifyMessageSignature(&para, 0,
signedWithCertWithValidPubKeyContent,
sizeof(signedWithCertWithValidPubKeyContent), decoded, &cbDecoded, NULL);
/* When a non-NULL buffer is provided, cbDecoded must not be too small */
ok(!ret && GetLastError() == ERROR_MORE_DATA,
"expected ERROR_MORE_DATA, got %d (%08x)\n", GetLastError(),
"expected ERROR_MORE_DATA, got %ld (%08lx)\n", GetLastError(),
GetLastError());
}
@@ -670,38 +623,38 @@ static void test_hash_message(void)
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got 0x%08x\n", GetLastError());
"expected E_INVALIDARG, got 0x%08lx\n", GetLastError());
para.cbSize = sizeof(para);
/* Not quite sure what "success" means in this case, but it does succeed */
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* With a bogus encoding type it "succeeds" */
para.dwMsgEncodingType = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* According to MSDN, the third parameter (cToBeHashed) must be 1 if the
* second parameter (fDetached) is FALSE, but again it "succeeds."
*/
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* Even passing parameters to hash results in "success." */
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL, NULL, NULL,
NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* Try again with a valid encoding type */
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* And with valid data to hash */
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL, NULL, NULL,
NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
/* But requesting the size of the hashed blob and indicating there's data
* to hash results in a crash
*/
@@ -719,7 +672,7 @@ static void test_hash_message(void)
ok(!ret &&
(GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
GetLastError() == CRYPT_E_OID_FORMAT), /* Vista */
"expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08x (%d)\n",
"expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08lx (%ld)\n",
GetLastError(), GetLastError());
para.HashAlgorithm.pszObjId = oid_rsa_md5;
/* With a valid hash algorithm, this succeeds, even though fDetached is
@@ -729,55 +682,55 @@ static void test_hash_message(void)
ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL,
&hashedBlobSize, NULL, NULL);
todo_wine
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
if (ret)
{
/* Actually attempting to get the hashed data fails, perhaps because
* detached is FALSE.
*/
hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize);
hashedBlob = malloc(hashedBlobSize);
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, hashedBlob,
&hashedBlobSize, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
"expected CRYPT_E_MSG_ERROR, got 0x%08x (%d)\n", GetLastError(),
"expected CRYPT_E_MSG_ERROR, got 0x%08lx (%ld)\n", GetLastError(),
GetLastError());
HeapFree(GetProcessHeap(), 0, hashedBlob);
free(hashedBlob);
}
/* Repeating tests with fDetached = TRUE results in success */
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
&hashedBlobSize, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
if (ret)
{
hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize);
hashedBlob = malloc(hashedBlobSize);
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, hashedBlob,
&hashedBlobSize, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
ok(hashedBlobSize == sizeof(detachedHashBlob),
"unexpected size of detached blob %d\n", hashedBlobSize);
"unexpected size of detached blob %ld\n", hashedBlobSize);
ok(!memcmp(hashedBlob, detachedHashBlob, hashedBlobSize),
"unexpected detached blob value\n");
HeapFree(GetProcessHeap(), 0, hashedBlob);
free(hashedBlob);
}
/* Hashing a single item with fDetached = FALSE also succeeds */
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, FALSE, 1, toHash, hashSize, NULL,
&hashedBlobSize, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
if (ret)
{
hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize);
hashedBlob = malloc(hashedBlobSize);
ret = CryptHashMessage(&para, FALSE, 1, toHash, hashSize, hashedBlob,
&hashedBlobSize, NULL, NULL);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
ok(hashedBlobSize == sizeof(hashBlob),
"unexpected size of detached blob %d\n", hashedBlobSize);
"unexpected size of detached blob %ld\n", hashedBlobSize);
ok(!memcmp(hashedBlob, hashBlob, hashedBlobSize),
"unexpected detached blob value\n");
HeapFree(GetProcessHeap(), 0, hashedBlob);
free(hashedBlob);
}
/* Check the computed hash value too. You don't need to get the encoded
* blob to get it.
@@ -785,21 +738,21 @@ static void test_hash_message(void)
computedHashSize = 0xdeadbeef;
ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
&hashedBlobSize, NULL, &computedHashSize);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(computedHashSize == 16, "expected hash size of 16, got %d\n",
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
ok(computedHashSize == 16, "expected hash size of 16, got %ld\n",
computedHashSize);
if (ret)
{
computedHash = HeapAlloc(GetProcessHeap(), 0, computedHashSize);
computedHash = malloc(computedHashSize);
SetLastError(0xdeadbeef);
ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
&hashedBlobSize, computedHash, &computedHashSize);
ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
ok(computedHashSize == sizeof(hashVal),
"unexpected size of hash value %d\n", computedHashSize);
"unexpected size of hash value %ld\n", computedHashSize);
ok(!memcmp(computedHash, hashVal, computedHashSize),
"unexpected value\n");
HeapFree(GetProcessHeap(), 0, computedHash);
free(computedHash);
}
}
@@ -1013,7 +966,7 @@ static void test_sign_message(void)
ok(!ret &&
(GetLastError() == E_INVALIDARG ||
GetLastError() == ERROR_ARITHMETIC_OVERFLOW), /* Win7 */
"expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08x\n",
"expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08lx\n",
GetLastError());
para.cbSize = sizeof(para);
para.dwMsgEncodingType = X509_ASN_ENCODING;
@@ -1021,37 +974,30 @@ static void test_sign_message(void)
signedBlobSize = 255;
ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
ok(!signedBlobSize, "unexpected size %d\n", signedBlobSize);
"expected E_INVALIDARG, got %08lx\n", GetLastError());
ok(!signedBlobSize, "unexpected size %ld\n", signedBlobSize);
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
signedBlobSize = 0;
ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
todo_wine
ok(signedBlobSize, "bad size\n");
SetLastError(0xdeadbeef);
ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptImportKey(hCryptProv, publicPrivateKeyPair,
sizeof(publicPrivateKeyPair), 0, 0, &hKey);
if (!ret && GetLastError() == NTE_PERM) /* Win9x */
{
skip("Failed to import a key\n");
if (hCryptProv)
CryptReleaseContext(hCryptProv, 0);
return;
}
ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
para.pSigningCert = CertCreateCertificateContext(X509_ASN_ENCODING |
PKCS_7_ASN_ENCODING, cert1, sizeof(cert1));
ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
para.HashAlgorithm.pszObjId = oid_rsa_md5;
@@ -1062,21 +1008,21 @@ static void test_sign_message(void)
SetLastError(0xdeadbeef);
ret = CertSetCertificateContextProperty(para.pSigningCert,
CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext);
ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
signedBlobSize = 0;
ret = CryptSignMessage(&para, TRUE, 0, NULL, NULL, NULL, &signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, TRUE, 0, NULL, NULL, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedHashForEmptyMessage),
"unexpected size %d\n", signedBlobSize);
"unexpected size %ld\n", signedBlobSize);
ok(!memcmp(signedBlob, signedHashForEmptyMessage, signedBlobSize),
"unexpected value\n");
CryptMemFree(signedBlob);
@@ -1085,15 +1031,15 @@ static void test_sign_message(void)
SetLastError(0xdeadbeef);
signedBlobSize = 0;
ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %d\n",
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %ld\n",
signedBlobSize);
ok(!memcmp(signedBlob, signedEmptyMessage, signedBlobSize),
"unexpected value\n");
@@ -1104,16 +1050,16 @@ static void test_sign_message(void)
signedBlobSize = 0;
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedHash),
"unexpected size of signed blob %d\n", signedBlobSize);
"unexpected size of signed blob %ld\n", signedBlobSize);
ok(!memcmp(signedBlob, signedHash, signedBlobSize),
"unexpected value\n");
CryptMemFree(signedBlob);
@@ -1126,16 +1072,16 @@ static void test_sign_message(void)
signedBlobSize = 0;
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedHashWithCert),
"unexpected size of signed blob %d\n", signedBlobSize);
"unexpected size of signed blob %ld\n", signedBlobSize);
ok(!memcmp(signedBlob, signedHashWithCert, signedBlobSize),
"unexpected value\n");
CryptMemFree(signedBlob);
@@ -1147,7 +1093,7 @@ static void test_sign_message(void)
SetLastError(0xdeadbeef);
crlContext = CertCreateCRLContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
crl, sizeof(crl));
ok(crlContext != NULL, "CertCreateCRLContext failed: %08x\n",
ok(crlContext != NULL, "CertCreateCRLContext failed: %08lx\n",
GetLastError());
para.rgpMsgCrl = &crlContext;
@@ -1155,16 +1101,16 @@ static void test_sign_message(void)
signedBlobSize = 0;
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedHashWithCRL),
"unexpected size of signed blob %d\n", signedBlobSize);
"unexpected size of signed blob %ld\n", signedBlobSize);
ok(!memcmp(signedBlob, signedHashWithCRL, signedBlobSize),
"unexpected value\n");
CryptMemFree(signedBlob);
@@ -1178,16 +1124,16 @@ static void test_sign_message(void)
signedBlobSize = 0;
ret = CryptSignMessage(&para, FALSE, 1, toSign, signSize, NULL,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
signedBlob = CryptMemAlloc(signedBlobSize);
if (signedBlob)
{
SetLastError(0xdeadbeef);
ret = CryptSignMessage(&para, FALSE, 1, toSign, signSize, signedBlob,
&signedBlobSize);
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
ok(signedBlobSize == sizeof(signedData),
"unexpected size of signed blob %d\n", signedBlobSize);
"unexpected size of signed blob %ld\n", signedBlobSize);
ok(!memcmp(signedBlob, signedData, signedBlobSize),
"unexpected value\n");
CryptMemFree(signedBlob);
@@ -1219,19 +1165,19 @@ static void test_encrypt_message(void)
DWORD encryptedBlobSize;
SetLastError(0xdeadbeef);
ret = pCryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING |
PKCS_7_ASN_ENCODING, cert1, sizeof(cert1));
ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
SetLastError(0xdeadbeef);
certs[1] = CertCreateCertificateContext(X509_ASN_ENCODING |
PKCS_7_ASN_ENCODING, cert2, sizeof(cert2));
ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08x\n",
ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
memset(&para, 0, sizeof(para));
@@ -1240,8 +1186,8 @@ static void test_encrypt_message(void)
ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
"expected E_INVALIDARG, got %08lx\n", GetLastError());
ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
para.cbSize = sizeof(para);
para.dwMsgEncodingType = X509_ASN_ENCODING;
SetLastError(0xdeadbeef);
@@ -1249,19 +1195,17 @@ static void test_encrypt_message(void)
ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
"expected E_INVALIDARG, got %08lx\n", GetLastError());
ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
encryptedBlobSize = 255;
ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
ok(!ret &&
(GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
GetLastError() == E_INVALIDARG), /* Win9x */
"expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n",
ok(!ret && GetLastError() == CRYPT_E_UNKNOWN_ALGO,
"expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n",
GetLastError());
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
para.hCryptProv = hCryptProv;
para.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4;
@@ -1270,9 +1214,7 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
ok(ret ||
broken(!ret) /* Win9x */,
"CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
if (ret)
{
encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1281,9 +1223,9 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, encryptedBlob,
&encryptedBlobSize);
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
ok(encryptedBlobSize == sizeof(encryptedMessage),
"unexpected size of encrypted blob %d\n", encryptedBlobSize);
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
ok(encryptedBlobSize == sizeof(encryptedMessage),
"unexpected size of encrypted blob %ld\n", encryptedBlobSize);
ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize),
"unexpected value\n");
CryptMemFree(encryptedBlob);
@@ -1294,7 +1236,7 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, NULL,
&encryptedBlobSize);
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
if (ret)
{
encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1303,7 +1245,7 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, encryptedBlob,
&encryptedBlobSize);
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
CryptMemFree(encryptedBlob);
}
}
@@ -1312,9 +1254,7 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(&para, 0, NULL, blob, sizeof(blob), NULL,
&encryptedBlobSize);
ok(ret ||
broken(!ret) /* Win9x */,
"CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
if (ret)
{
encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1323,13 +1263,11 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(&para, 0, NULL, blob, sizeof(blob),
encryptedBlob, &encryptedBlobSize);
ok(ret ||
broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
"CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
if (ret)
{
ok(encryptedBlobSize == 55,
"unexpected size of encrypted blob %d\n", encryptedBlobSize);
"unexpected size of encrypted blob %ld\n", encryptedBlobSize);
}
CryptMemFree(encryptedBlob);
}
@@ -1339,7 +1277,7 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(&para, 2, certs, blob, sizeof(blob), NULL,
&encryptedBlobSize);
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
if (ret)
{
encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1348,9 +1286,7 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(&para, 2, certs, blob, sizeof(blob),
encryptedBlob, &encryptedBlobSize);
ok(ret ||
broken(!ret), /* some Win95 and some NT4 */
"CryptEncryptMessage failed: %08x\n", GetLastError());
ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
CryptMemFree(encryptedBlob);
}
}
@@ -1365,8 +1301,6 @@ static void test_encrypt_message(void)
START_TEST(message)
{
init_function_pointers();
test_msg_get_signer_count();
test_verify_detached_message_hash();
test_verify_message_hash();
File diff suppressed because it is too large Load Diff
+178 -77
View File
@@ -26,9 +26,6 @@
#include "wine/test.h"
static BOOL (WINAPI * pCryptQueryObject)(DWORD, const void *, DWORD, DWORD,
DWORD, DWORD *, DWORD *, DWORD *, HCERTSTORE *, HCRYPTMSG *, const void **);
static BYTE bigCert[] = {
0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,
0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
@@ -45,18 +42,10 @@ static char bigCertBase64[] =
"MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEwMDAw\n"
"MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n"
"AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n";
static WCHAR bigCertBase64W[] = {
'M','H','o','C','A','Q','E','w','A','g','Y','A','M','B','U','x','E','z','A',
'R','B','g','N','V','B','A','M','T','C','k','p','1','Y','W','4','g','T','G',
'F','u','Z','w','A','w','I','h','g','P','M','T','Y','w','M','T','A','x','M',
'D','E','w',',','D','A','w','\n',
'M','D','B','a','G','A','8','x','N','j','A','x','M','D','E','w','M','T','A',
'w','M','D','A','w','M','F','o','w','F','T','E','T','M','B','E','G','A','1',
'U','E','A','x','M','K','S','n','V','h','b','i','B','M','Y','W','5','n','A',
'D','A','H','M','A','I','G','\n',
'A','A','M','B','A','K','M','W','M','B','Q','w','E','g','Y','D','V','R','0',
'T','A','Q','H','/','B','A','g','w','B','g','E','B','/','w','I','B','A','Q',
'=','=','\n',0 };
static WCHAR bigCertBase64W[] =
L"MHoCAQEwAgYAMBUxEzARBgNVBAMTCkp1YW4gTGFuZwAwIhgPMTYwMTAxMDEw,DAw\n"
"MDBaGA8xNjAxMDEwMTAwMDAwMFowFTETMBEGA1UEAxMKSnVhbiBMYW5nADAHMAIG\n"
"AAMBAKMWMBQwEgYDVR0TAQH/BAgwBgEB/wIBAQ==\n";
static BYTE signedWithCertWithValidPubKeyContent[] = {
0x30,0x82,0x01,0x89,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,
0xa0,0x82,0x01,0x7a,0x30,0x82,0x01,0x76,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,
@@ -95,88 +84,190 @@ static char signedWithCertWithValidPubKeyContentBase64[] =
"EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw"
"s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g"
"7pMZOVHkRLgLKPSoDQ==";
static WCHAR signedWithCertWithValidPubKeyContentBase64W[] = {
'M','I','I','B','i','Q','Y','J','K','o','Z','I','h','v','c','N','A','Q','c','C',
'o','I','I','B','e','j','C','C','A','X','Y','C','A','Q','E','x','D','j','A','M',
'B','g','g','q','h','k','i','G','9','w','0','C','B','Q','U','A','M','B','M','G',
'C','S','q','G','S','I','b','3','D','Q','E','H','A','a','A','G','B','A','Q','B',
'A','g','M','E','o','I','H','S','M','I','H','P','A','g','E','B','M','A','I','G',
'A','D','A','V','M','R','M','w','E','Q','Y','D','V','Q','Q','D','E','w','p','K',
'd','W','F','u','I','E','x','h','b','m','c','A','M','C','I','Y','D','z','E','2',
'M','D','E','w','M','T','A','x','M','D','A','w','M','D','A','w','W','h','g','P',
'M','T','Y','w','M','T','A','x','M','D','E','w','M','D','A','w','M','D','B','a',
'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1',
'Y','W','4','g','T','G','F','u','Z','w','A','w','X','D','A','N','B','g','k','q',
'h','k','i','G','9','w','0','B','A','Q','E','F','A','A','N','L','A','D','B','I',
'A','k','E','A','4','l','Q','6','p','4','O','x','J','x','Q','+','W','b','u','0',
'U','+','Y','f','5','1','3','x','I','W','i','t','h','V','P','b','a','x','7','r',
'Z','Z','c','D','h','m','D','e','8','2','w','4','d','e','B','M','Y','b','u','8',
'Y','h','e','p','z','X','k','/','I','U','6','W','y','w','7','c','Y','Z','Q','w',
'G','B','B','r','0','B','w','Q','e','Q','I','D','A','Q','A','B','o','x','Y','w',
'F','D','A','S','B','g','N','V','H','R','M','B','A','f','8','E','C','D','A','G',
'A','Q','H','/','A','g','E','B','M','X','c','w','d','Q','I','B','A','T','A','a',
'M','B','U','x','E','z','A','R','B','g','N','V','B','A','M','T','C','k','p','1',
'Y','W','4','g','T','G','F','u','Z','w','A','C','A','Q','E','w','D','A','Y','I',
'K','o','Z','I','h','v','c','N','A','g','U','F','A','D','A','E','B','g','A','F',
'A','A','R','A','g','a','Z','w','s','+','9','Z','0','W','b','R','m','8','C','a',
't','p','p','e','b','W','9','t','D','V','m','p','q','m','7','p','L','K','A','e',
'7','s','J','g','v','F','m','+','P','2','M','G','j','c','k','R','H','S','N','k',
'k','u','8','u','/','F','c','p','p','K','/','g','7','p','M','Z','O','V','H','k',
'R','L','g','L','K','P','S','o','D','Q','=','=',0 };
static WCHAR signedWithCertWithValidPubKeyContentBase64W[] =
L"MIIBiQYJKoZIhvcNAQcCoIIBejCCAXYCAQExDjAMBggqhkiG9w0CBQUAMBMGCSqG"
"SIb3DQEHAaAGBAQBAgMEoIHSMIHPAgEBMAIGADAVMRMwEQYDVQQDEwpKdWFuIExh"
"bmcAMCIYDzE2MDEwMTAxMDAwMDAwWhgPMTYwMTAxMDEwMDAwMDBaMBUxEzARBgNV"
"BAMTCkp1YW4gTGFuZwAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA4lQ6p4OxJxQ+"
"Wbu0U+Yf513xIWithVPbax7rZZcDhmDe82w4deBMYbu8YhepzXk/IU6Wyw7cYZQw"
"GBBr0BwQeQIDAQABoxYwFDASBgNVHRMBAf8ECDAGAQH/AgEBMXcwdQIBATAaMBUx"
"EzARBgNVBAMTCkp1YW4gTGFuZwACAQEwDAYIKoZIhvcNAgUFADAEBgAFAARAgaZw"
"s+9Z0WbRm8CatppebW9tDVmpqm7pLKAe7sJgvFm+P2MGjckRHSNkku8u/FcppK/g"
"7pMZOVHkRLgLKPSoDQ==";
/* Self-signed .exe, built with tcc, signed with signtool
* (and a certificate generated on a self-signed CA).
*
* small.c:
* int _start()
* {
* return 0;
* }
*
* tcc -nostdlib small.c
* signtool sign /v /f codesign.pfx small.exe
*/
static const BYTE signed_pe_blob[] =
{
0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD,
0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F,
0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A,
0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x4C,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0x00,0x0F,0x03,0x0B,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,
0xE7,0x0C,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x68,0x05,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x89,0xE5,0x81,0xEC,0x00,0x00,0x00,0x00,0x90,0xB8,0x00,0x00,0x00,0x00,0xE9,
0x00,0x00,0x00,0x00,0xC9,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00,
/* Start of the signature overlay */
0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02,
0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,
0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30,
0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,
0x14,0xA0,0x95,0xDE,0xBD,0x1A,0xB7,0x86,0xAF,0x50,0x63,0xD8,0x8F,0x90,0xD5,0x49,0x96,0x4E,0x44,0xF0,0x71,0xA0,0x82,0x03,
0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,
0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,
0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,
0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64,
0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC,
0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C,
0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05,
0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5,
0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A,
0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E,
0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51,
0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80,
0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0,
0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95,
0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A,
0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55,
0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04,
0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30,
0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86,
0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20,
0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB,
0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5,
0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD,
0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC,
0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0,
0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04,
0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67,
0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74,
0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C,
0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6,
0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30,
0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53,
0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,
0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06,
0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,
0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,
0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x3D,
0x08,0xC8,0xA3,0xEE,0x05,0x1A,0x61,0xD9,0xFE,0x1A,0x63,0xC0,0x8A,0x6E,0x9D,0xF9,0xC3,0x13,0x98,0x30,0x0D,0x06,0x09,0x2A,
0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x90,0xF9,0xC0,0x7F,0x1D,0x70,0x8C,0x04,0x22,0x82,
0xB6,0x2D,0x48,0xBF,0x30,0x51,0x29,0xF8,0xE3,0x11,0x39,0xE0,0x64,0x23,0x72,0xE2,0x4C,0x09,0x9F,0x39,0xF2,0x6F,0xDD,0xB9,
0x5A,0x3D,0xEF,0xEB,0xBE,0xEC,0x3B,0xE6,0x58,0x4C,0xC9,0x4F,0xED,0xCB,0x6E,0x9D,0x67,0x8E,0x89,0x92,0x40,0x39,0xA2,0x5F,
0xF9,0xEF,0xD3,0xF5,0x24,0x27,0x8D,0xF7,0x3C,0x92,0x66,0x56,0xC8,0x2B,0xEA,0x04,0xA1,0x0E,0xDA,0x89,0x30,0xA7,0x01,0xD8,
0x0B,0xF8,0xFD,0x99,0xB6,0xC0,0x38,0xB0,0x21,0x50,0x3A,0x86,0x01,0xD0,0xF3,0x86,0x72,0xE3,0x5A,0xBB,0x2A,0x6E,0xBD,0xFB,
0x22,0xF9,0x42,0xD3,0x04,0xFE,0x8D,0xD8,0x79,0xD1,0xEE,0x61,0xC6,0x48,0x04,0x99,0x9A,0xA2,0x73,0xE5,0xFB,0x24,0x10,0xD5,
0x6B,0x71,0x80,0x0E,0x09,0xEA,0x85,0x9A,0xBD,0xBB,0xDE,0x99,0x5D,0xA3,0x18,0x4D,0xED,0x20,0x73,0x3E,0x32,0xEF,0x2C,0xAC,
0x5A,0x83,0x87,0x1F,0x7F,0x19,0x61,0x35,0x53,0xC1,0xAA,0x89,0x97,0xB3,0xDD,0x8D,0xA8,0x67,0x5B,0xC2,0xE2,0x09,0xB7,0xDD,
0x6A,0xCB,0xD5,0xBF,0xD6,0x08,0xE2,0x23,0x1A,0x41,0x9D,0xD5,0x6A,0x6B,0x8D,0x3C,0x29,0x1B,0xF1,0x3F,0x4E,0x4A,0x8F,0x29,
0x33,0xF9,0x1C,0x60,0xA0,0x92,0x7E,0x4F,0x35,0xB8,0xDD,0xEB,0xD1,0x68,0x1A,0x9D,0xA2,0xA6,0x97,0x1F,0x5F,0xC6,0x2C,0xFB,
0xCA,0xDF,0xF7,0x95,0x33,0x95,0xD4,0x79,0x5C,0x73,0x87,0x49,0x1F,0x8C,0x6E,0xCE,0x3E,0x6D,0x3D,0x2B,0x6B,0xD7,0x66,0xE9,
0x88,0x6F,0xF2,0x83,0xB9,0x9B,0x00,0x00
};
static void test_query_object(void)
{
WCHAR tmp_path[MAX_PATH];
BOOL ret;
CRYPT_DATA_BLOB blob;
DWORD content_type;
/* Test the usual invalid arguments */
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
ret = CryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
"expected E_INVALIDARG, got %08lx\n", GetLastError());
/* Test with a simple cert */
blob.pbData = bigCert;
blob.cbData = sizeof(bigCert);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
/* The same cert, base64-encoded */
blob.pbData = (BYTE *)bigCertBase64;
blob.cbData = sizeof(bigCertBase64);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
/* The same base64-encoded cert, restricting the format types */
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
"expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
"expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
/* The same cert, base64-encoded but as a wide character string */
blob.pbData = (BYTE *)bigCertBase64W;
blob.cbData = sizeof(bigCertBase64W);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
"expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
"expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
/* For brevity, not tested here, but tested on Windows: same failure
* (CRYPT_E_NO_MATCH) when the wide character base64-encoded cert
* is written to a file and queried.
@@ -185,51 +276,61 @@ static void test_query_object(void)
blob.pbData = signedWithCertWithValidPubKeyContent;
blob.cbData = sizeof(signedWithCertWithValidPubKeyContent);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64;
blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
/* A valid signed message, encoded as a wide character base64 string, can
* be queried successfully.
*/
blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64W;
blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64W);
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
"expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
"expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
GetEnvironmentVariableW( L"TMP", tmp_path, MAX_PATH );
SetEnvironmentVariableW(L"TMP", L"C:\\nonexistent");
blob.pbData = (BYTE *)signed_pe_blob;
blob.cbData = sizeof(signed_pe_blob);
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &content_type,
NULL, NULL, NULL, NULL);
ok(!ret, "CryptQueryObject succeeded\n");
ok(GetLastError() == CRYPT_E_NO_MATCH, "Unexpected error %lu.\n", GetLastError());
SetEnvironmentVariableW(L"TMP", tmp_path);
blob.pbData = (BYTE *)signed_pe_blob;
blob.cbData = sizeof(signed_pe_blob);
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &content_type,
NULL, NULL, NULL, NULL);
ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
ok(content_type == CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED,
"Got unexpected content_type %#lx.\n", content_type);
}
START_TEST(object)
{
HMODULE mod = GetModuleHandleA("crypt32.dll");
pCryptQueryObject = (void *)GetProcAddress(mod, "CryptQueryObject");
if (!pCryptQueryObject)
{
win_skip("CryptQueryObject is not available\n");
return;
}
test_query_object();
}
+175 -202
View File
@@ -29,93 +29,86 @@
#include "wine/test.h"
static BOOL (WINAPI *pCryptEnumOIDInfo)(DWORD,DWORD,void*,PFN_CRYPT_ENUM_OID_INFO);
struct OIDToAlgID
{
LPCSTR oid;
LPCSTR altOid;
DWORD algID;
DWORD altAlgID;
};
static const struct OIDToAlgID oidToAlgID[] = {
{ szOID_RSA_RSA, NULL, CALG_RSA_KEYX },
{ szOID_RSA_MD2RSA, NULL, CALG_MD2 },
{ szOID_RSA_MD4RSA, NULL, CALG_MD4 },
{ szOID_RSA_MD5RSA, NULL, CALG_MD5 },
{ szOID_RSA_SHA1RSA, NULL, CALG_SHA },
{ szOID_RSA_DH, NULL, CALG_DH_SF },
{ szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM },
{ szOID_RSA_SMIMEalgCMS3DESwrap, NULL, CALG_3DES },
{ szOID_RSA_SMIMEalgCMSRC2wrap, NULL, CALG_RC2 },
{ szOID_RSA_MD2, NULL, CALG_MD2 },
{ szOID_RSA_MD4, NULL, CALG_MD4 },
{ szOID_RSA_MD5, NULL, CALG_MD5 },
{ szOID_RSA_RC2CBC, NULL, CALG_RC2 },
{ szOID_RSA_RC4, NULL, CALG_RC4 },
{ szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES },
{ szOID_ANSI_X942_DH, NULL, CALG_DH_SF },
{ szOID_X957_DSA, NULL, CALG_DSS_SIGN },
{ szOID_X957_SHA1DSA, NULL, CALG_SHA },
{ szOID_OIWSEC_md4RSA, NULL, CALG_MD4 },
{ szOID_OIWSEC_md5RSA, NULL, CALG_MD5 },
{ szOID_OIWSEC_md4RSA2, NULL, CALG_MD4 },
{ szOID_OIWSEC_desCBC, NULL, CALG_DES },
{ szOID_OIWSEC_dsa, NULL, CALG_DSS_SIGN },
{ szOID_OIWSEC_shaDSA, NULL, CALG_SHA },
{ szOID_OIWSEC_shaRSA, NULL, CALG_SHA },
{ szOID_OIWSEC_sha, NULL, CALG_SHA },
{ szOID_OIWSEC_rsaXchg, NULL, CALG_RSA_KEYX },
{ szOID_OIWSEC_sha1, NULL, CALG_SHA },
{ szOID_OIWSEC_dsaSHA1, NULL, CALG_SHA },
{ szOID_OIWSEC_sha1RSASign, NULL, CALG_SHA },
{ szOID_OIWDIR_md2RSA, NULL, CALG_MD2 },
{ szOID_INFOSEC_mosaicUpdatedSig, NULL, CALG_SHA },
{ szOID_INFOSEC_mosaicKMandUpdSig, NULL, CALG_DSS_SIGN },
{ szOID_NIST_sha256, NULL, CALG_SHA_256, -1 },
{ szOID_NIST_sha384, NULL, CALG_SHA_384, -1 },
{ szOID_NIST_sha512, NULL, CALG_SHA_512, -1 }
{ szOID_RSA_RSA, CALG_RSA_KEYX },
{ szOID_RSA_MD2RSA, CALG_MD2 },
{ szOID_RSA_MD4RSA, CALG_MD4 },
{ szOID_RSA_MD5RSA, CALG_MD5 },
{ szOID_RSA_SHA1RSA, CALG_SHA },
{ szOID_RSA_DH, CALG_DH_SF },
{ szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM },
{ szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES },
{ szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 },
{ szOID_RSA_MD2, CALG_MD2 },
{ szOID_RSA_MD4, CALG_MD4 },
{ szOID_RSA_MD5, CALG_MD5 },
{ szOID_RSA_RC2CBC, CALG_RC2 },
{ szOID_RSA_RC4, CALG_RC4 },
{ szOID_RSA_DES_EDE3_CBC, CALG_3DES },
{ szOID_ANSI_X942_DH, CALG_DH_SF },
{ szOID_X957_DSA, CALG_DSS_SIGN },
{ szOID_X957_SHA1DSA, CALG_SHA },
{ szOID_OIWSEC_md4RSA, CALG_MD4 },
{ szOID_OIWSEC_md5RSA, CALG_MD5 },
{ szOID_OIWSEC_md4RSA2, CALG_MD4 },
{ szOID_OIWSEC_desCBC, CALG_DES },
{ szOID_OIWSEC_dsa, CALG_DSS_SIGN },
{ szOID_OIWSEC_shaDSA, CALG_SHA },
{ szOID_OIWSEC_shaRSA, CALG_SHA },
{ szOID_OIWSEC_sha, CALG_SHA },
{ szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX },
{ szOID_OIWSEC_sha1, CALG_SHA },
{ szOID_OIWSEC_dsaSHA1, CALG_SHA },
{ szOID_OIWSEC_sha1RSASign, CALG_SHA },
{ szOID_OIWDIR_md2RSA, CALG_MD2 },
{ szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA },
{ szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN },
{ szOID_NIST_sha256, CALG_SHA_256, -1 },
{ szOID_NIST_sha384, CALG_SHA_384, -1 },
{ szOID_NIST_sha512, CALG_SHA_512, -1 },
{ szOID_ECC_PUBLIC_KEY, CALG_OID_INFO_PARAMETERS },
};
static const struct OIDToAlgID algIDToOID[] = {
{ szOID_RSA_RSA, NULL, CALG_RSA_KEYX },
{ szOID_RSA_SMIMEalgESDH, NULL, CALG_DH_EPHEM },
{ szOID_RSA_MD2, NULL, CALG_MD2 },
{ szOID_RSA_MD4, NULL, CALG_MD4 },
{ szOID_RSA_MD5, NULL, CALG_MD5 },
{ szOID_RSA_RC2CBC, NULL, CALG_RC2 },
{ szOID_RSA_RC4, NULL, CALG_RC4 },
{ szOID_RSA_DES_EDE3_CBC, NULL, CALG_3DES },
{ szOID_ANSI_X942_DH, NULL, CALG_DH_SF },
{ szOID_X957_DSA, szOID_OIWSEC_dsa /* some Win98 */, CALG_DSS_SIGN },
{ szOID_OIWSEC_desCBC, NULL, CALG_DES },
{ szOID_OIWSEC_sha1, NULL, CALG_SHA },
{ szOID_RSA_RSA, CALG_RSA_KEYX },
{ szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM },
{ szOID_RSA_MD2, CALG_MD2 },
{ szOID_RSA_MD4, CALG_MD4 },
{ szOID_RSA_MD5, CALG_MD5 },
{ szOID_RSA_RC2CBC, CALG_RC2 },
{ szOID_RSA_RC4, CALG_RC4 },
{ szOID_RSA_DES_EDE3_CBC, CALG_3DES },
{ szOID_ANSI_X942_DH, CALG_DH_SF },
{ szOID_X957_DSA, CALG_DSS_SIGN },
{ szOID_OIWSEC_desCBC, CALG_DES },
{ szOID_OIWSEC_sha1, CALG_SHA },
};
static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 };
static const WCHAR bogus2Dll[] = { 'b','o','g','u','s','2','.','d','l','l',0 };
static void testOIDToAlgID(void)
static void test_OIDToAlgID(void)
{
int i;
DWORD alg;
/* Test with a bogus one */
alg = CertOIDToAlgId("1.2.3");
ok(!alg, "Expected failure, got %d\n", alg);
ok(!alg, "Expected failure, got %ld\n", alg);
for (i = 0; i < ARRAY_SIZE(oidToAlgID); i++)
{
alg = CertOIDToAlgId(oidToAlgID[i].oid);
ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID),
"Expected %d, got %d\n", oidToAlgID[i].algID, alg);
"Expected %ld, got %ld\n", oidToAlgID[i].algID, alg);
}
}
static void testAlgIDToOID(void)
static void test_AlgIDToOID(void)
{
int i;
LPCSTR oid;
@@ -124,32 +117,14 @@ static void testAlgIDToOID(void)
SetLastError(0xdeadbeef);
oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80);
ok(!oid && GetLastError() == 0xdeadbeef,
"Didn't expect last error (%08x) to be set\n", GetLastError());
"Didn't expect last error (%08lx) to be set\n", GetLastError());
for (i = 0; i < ARRAY_SIZE(algIDToOID); i++)
{
oid = CertAlgIdToOID(algIDToOID[i].algID);
/* Allow failure, not every version of Windows supports every algo */
ok(oid != NULL || broken(!oid), "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid);
ok(oid != NULL, "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid);
if (oid)
{
if (strcmp(oid, algIDToOID[i].oid))
{
if (algIDToOID[i].altOid)
ok(!strcmp(oid, algIDToOID[i].altOid),
"Expected %s or %s, got %s\n", algIDToOID[i].oid,
algIDToOID[i].altOid, oid);
else
{
/* No need to rerun the test, we already know it failed. */
ok(0, "Expected %s, got %s\n", algIDToOID[i].oid, oid);
}
}
else
{
/* No need to rerun the test, we already know it succeeded. */
ok(1, "Expected %s, got %s\n", algIDToOID[i].oid, oid);
}
}
ok(!strcmp(oid, algIDToOID[i].oid), "Expected %s, got %s\n", algIDToOID[i].oid, oid);
}
}
@@ -166,7 +141,7 @@ static void test_oidFunctionSet(void)
/* The name doesn't mean much */
set1 = CryptInitOIDFunctionSet("funky", 0);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
if (set1)
{
/* These crash
@@ -175,26 +150,26 @@ static void test_oidFunctionSet(void)
*/
size = 0;
ret = CryptGetDefaultOIDDllList(set1, 0, NULL, &size);
ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n", GetLastError());
ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n", GetLastError());
if (ret)
{
buf = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
buf = malloc(size * sizeof(WCHAR));
if (buf)
{
ret = CryptGetDefaultOIDDllList(set1, 0, buf, &size);
ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n",
ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n",
GetLastError());
ok(!*buf, "Expected empty DLL list\n");
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
}
}
/* MSDN says flags must be 0, but it's not checked */
set1 = CryptInitOIDFunctionSet("", 1);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
set2 = CryptInitOIDFunctionSet("", 0);
ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
/* There isn't a free function, so there must be only one set per name to
* limit leaks. (I guess the sets are freed when crypt32 is unloaded.)
*/
@@ -208,7 +183,7 @@ static void test_oidFunctionSet(void)
/* There's no installed function for a built-in encoding. */
set1 = CryptInitOIDFunctionSet("CryptDllEncodeObject", 0);
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
if (set1)
{
void *funcAddr;
@@ -216,9 +191,8 @@ static void test_oidFunctionSet(void)
ret = CryptGetOIDFunctionAddress(set1, X509_ASN_ENCODING, X509_CERT, 0,
&funcAddr, &hFuncAddr);
ok((!ret && GetLastError() == ERROR_FILE_NOT_FOUND) ||
broken(ret) /* some Win98 */,
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
}
}
@@ -243,21 +217,21 @@ static void test_installOIDFunctionAddress(void)
SetLastError(0xdeadbeef);
ret = CryptInstallOIDFunctionAddress(NULL, 0, "CryptDllEncodeObject", 0,
NULL, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
GetLastError());
/* The function name doesn't much matter */
SetLastError(0xdeadbeef);
ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 0, NULL, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
GetLastError());
SetLastError(0xdeadbeef);
entry.pszOID = X509_CERT;
ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 1, &entry, 0);
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
GetLastError());
set = CryptInitOIDFunctionSet("OhSoFunky", 0);
ok(set != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
ok(set != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
if (set)
{
funcY funcAddr = NULL;
@@ -269,17 +243,15 @@ static void test_installOIDFunctionAddress(void)
*/
ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0,
(void **)&funcAddr, &hFuncAddr);
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == E_INVALIDARG /* some Win98 */),
"Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %d\n",
GetLastError());
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0,
(void **)&funcAddr, &hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
ret = CryptGetOIDFunctionAddress(set, 0, X509_CERT, 0,
(void **)&funcAddr, &hFuncAddr);
ok(ret, "CryptGetOIDFunctionAddress failed: %d\n", GetLastError());
ok(ret, "CryptGetOIDFunctionAddress failed: %ld\n", GetLastError());
if (funcAddr)
{
int y = funcAddr(0xabadc0da);
@@ -298,55 +270,55 @@ static void test_registerOIDFunction(void)
* omitted. This may be a side effect of the registry code, I don't know.
* I don't check it because I doubt anyone would depend on it.
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, NULL,
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
*/
/* On windows XP, GetLastError is incorrectly being set with an HRESULT,
* E_INVALIDARG
*/
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll,
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, L"bogus.dll",
NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG: %d\n", GetLastError());
"Expected E_INVALIDARG: %ld\n", GetLastError());
/* This has no effect, but "succeeds" on XP */
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo",
"1.2.3.4.5.6.7.8.9.10", NULL, NULL);
ok(ret, "Expected pseudo-success, got %d\n", GetLastError());
ok(ret, "Expected pseudo-success, got %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
{
skip("Need admin rights\n");
return;
}
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
/* Unwanted Cryptography\OID\EncodingType 1\bogus\ will still be there */
ok(!RegDeleteKeyA(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Cryptography\\OID\\EncodingType 1\\bogus"),
"Could not delete bogus key\n");
/* Shouldn't have effect but registry keys are created */
ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptUnregisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
/* Check with bogus encoding type. Registry keys are still created */
ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptUnregisterOIDFunction(0, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
/* Unwanted Cryptography\OID\EncodingType 0\CryptDllEncodeObject\
* will still be there
*/
@@ -357,11 +329,11 @@ static void test_registerOIDFunction(void)
* (for now) treated as a mask. Registry keys are created.
*/
ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
"1.2.3.4.5.6.7.8.9.10", L"bogus.dll", NULL);
ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject",
"1.2.3.4.5.6.7.8.9.10");
ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
/* Unwanted Cryptography\OID\EncodingType 3\CryptDllEncodeObject
* will still be there.
*/
@@ -385,84 +357,81 @@ static void test_registerDefaultOIDFunction(void)
ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, NULL);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
/* This succeeds on WinXP, although the bogus entry is unusable.
ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, bogusDll);
ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, L"bogus.dll");
*/
/* Register one at index 0 */
SetLastError(0xdeadbeef);
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
L"bogus.dll");
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
{
skip("Need admin rights\n");
return;
}
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
/* Reregistering should fail */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
L"bogus.dll");
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
"Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
/* Registering the same one at index 1 should also fail */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
bogusDll);
L"bogus.dll");
ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
"Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
"Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
/* Registering a different one at index 1 succeeds */
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
bogus2Dll);
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
L"bogus2.dll");
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
sprintf(buf, fmt, 0, func);
rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, buf, &key);
ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %d\n", rc);
ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %ld\n", rc);
if (rc == 0)
{
static const CHAR dllA[] = "Dll";
static const CHAR bogusDll_A[] = "bogus.dll";
static const CHAR bogus2Dll_A[] = "bogus2.dll";
CHAR dllBuf[MAX_PATH];
DWORD type, size;
LPSTR ptr;
size = ARRAY_SIZE(dllBuf);
rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size);
rc = RegQueryValueExA(key, "Dll", NULL, &type, (LPBYTE)dllBuf, &size);
ok(rc == 0,
"Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc);
ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %d\n", type);
/* bogusDll was registered first, so that should be first */
"Expected Dll value to exist, RegQueryValueExA failed: %ld\n", rc);
ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %ld\n", type);
/* bogus.dll was registered first, so that should be first */
ptr = dllBuf;
ok(!lstrcmpiA(ptr, bogusDll_A), "Unexpected dll\n");
ok(!lstrcmpiA(ptr, "bogus.dll"), "Unexpected dll\n");
ptr += lstrlenA(ptr) + 1;
ok(!lstrcmpiA(ptr, bogus2Dll_A), "Unexpected dll\n");
ok(!lstrcmpiA(ptr, "bogus2.dll"), "Unexpected dll\n");
RegCloseKey(key);
}
/* Unregister both of them */
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogusDll);
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
L"bogus.dll");
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
GetLastError());
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogus2Dll);
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
L"bogus2.dll");
ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
GetLastError());
/* Now that they're both unregistered, unregistering should fail */
ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
bogusDll);
L"bogus.dll");
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
/* Repeat a few tests on the normal encoding type */
ret = CryptRegisterDefaultOIDFunction(X509_ASN_ENCODING,
"CertDllOpenStoreProv", 0, bogusDll);
"CertDllOpenStoreProv", 0, L"bogus.dll");
ok(ret, "CryptRegisterDefaultOIDFunction failed\n");
ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING,
"CertDllOpenStoreProv", bogusDll);
"CertDllOpenStoreProv", L"bogus.dll");
ok(ret, "CryptUnregisterDefaultOIDFunction failed\n");
ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING,
"CertDllOpenStoreProv", bogusDll);
"CertDllOpenStoreProv", L"bogus.dll");
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
}
static void test_getDefaultOIDFunctionAddress(void)
@@ -480,34 +449,34 @@ static void test_getDefaultOIDFunctionAddress(void)
&hFuncAddr);
*/
set = CryptInitOIDFunctionSet("CertDllOpenStoreProv", 0);
ok(set != 0, "CryptInitOIDFunctionSet failed: %d\n", GetLastError());
ok(set != 0, "CryptInitOIDFunctionSet failed: %ld\n", GetLastError());
/* This crashes if hFuncAddr is not 0 to begin with */
hFuncAddr = 0;
ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
&hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
/* This fails with the normal encoding too, so built-in functions aren't
* returned.
*/
ret = CryptGetDefaultOIDFunctionAddress(set, X509_ASN_ENCODING, NULL, 0,
&funcAddr, &hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
/* Even with a registered dll, this fails (since the dll doesn't exist) */
SetLastError(0xdeadbeef);
ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
bogusDll);
L"bogus.dll");
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
skip("Need admin rights\n");
else
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
&hFuncAddr);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", bogusDll);
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", L"bogus.dll");
}
static BOOL WINAPI countOidInfo(PCCRYPT_OID_INFO pInfo, void *pvArg)
@@ -526,29 +495,22 @@ static void test_enumOIDInfo(void)
BOOL ret;
DWORD count = 0;
if (!pCryptEnumOIDInfo)
{
win_skip("CryptEnumOIDInfo() is not available\n");
return;
}
/* This crashes
ret = pCryptEnumOIDInfo(7, 0, NULL, NULL);
ret = CryptEnumOIDInfo(7, 0, NULL, NULL);
*/
/* Silly tests, check that more than one thing is enumerated */
ret = pCryptEnumOIDInfo(0, 0, &count, countOidInfo);
ret = CryptEnumOIDInfo(0, 0, &count, countOidInfo);
ok(ret && count > 0, "Expected more than item enumerated\n");
ret = pCryptEnumOIDInfo(0, 0, NULL, noOidInfo);
ret = CryptEnumOIDInfo(0, 0, NULL, noOidInfo);
ok(!ret, "Expected FALSE\n");
}
static void test_findOIDInfo(void)
{
static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 };
static WCHAR sha1[] = { 's','h','a','1',0 };
static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256;
static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256;
static CHAR oid_ecc_public_key[] = szOID_ECC_PUBLIC_KEY;
ALG_ID alg = CALG_SHA1;
ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN };
const struct oid_info
@@ -561,7 +523,7 @@ static void test_findOIDInfo(void)
} oid_test_info [] =
{
{ CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, szOID_RSA_MD5, CALG_MD5 },
{ CRYPT_OID_INFO_NAME_KEY, sha1, szOID_OIWSEC_sha1, CALG_SHA1 },
{ CRYPT_OID_INFO_NAME_KEY, (void *)L"sha1", szOID_OIWSEC_sha1, CALG_SHA1 },
{ CRYPT_OID_INFO_ALGID_KEY, &alg, szOID_OIWSEC_sha1, CALG_SHA1 },
{ CRYPT_OID_INFO_SIGN_KEY, algs, szOID_RSA_MD5RSA, CALG_MD5 },
{ CRYPT_OID_INFO_OID_KEY, oid_sha256, szOID_NIST_sha256, CALG_SHA_256, -1 },
@@ -581,8 +543,8 @@ static void test_findOIDInfo(void)
if (info)
{
ok(!strcmp(info->pszOID, test->oid), "Unexpected OID %s, expected %s\n", info->pszOID, test->oid);
ok(U(*info).Algid == test->algid || broken(U(*info).Algid == test->broken_algid),
"Unexpected Algid %d, expected %d\n", U(*info).Algid, test->algid);
ok(info->Algid == test->algid || broken(info->Algid == test->broken_algid),
"Unexpected Algid %d, expected %d\n", info->Algid, test->algid);
}
}
@@ -591,20 +553,20 @@ static void test_findOIDInfo(void)
{
DWORD *data;
ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\n", info->cbSize);
ok(info->cbSize == sizeof(*info), "Unexpected structure size %ld.\n", info->cbSize);
ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID);
ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n",
wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName));
ok(!lstrcmpW(info->pwszName, L"sha256ECDSA"), "Expected %s, got %s\n",
wine_dbgstr_w(L"sha256ECDSA"), wine_dbgstr_w(info->pwszName));
ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID,
"Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId);
ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY,
"Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid);
"Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %lu\n", info->dwGroupId);
ok(info->Algid == CALG_OID_INFO_CNG_ONLY,
"Expected CALG_OID_INFO_CNG_ONLY, got %d\n", info->Algid);
data = (DWORD *)info->ExtraInfo.pbData;
ok(info->ExtraInfo.cbData == 8, "Expected 8, got %d\n", info->ExtraInfo.cbData);
ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]);
ok(info->ExtraInfo.cbData == 8, "Expected 8, got %ld\n", info->ExtraInfo.cbData);
ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %lx\n", data[0]);
ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG,
"Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]);
"Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %lx\n", data[1]);
ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n",
wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid));
@@ -613,11 +575,21 @@ static void test_findOIDInfo(void)
}
else
win_skip("Host does not support ECDSA_SHA256, skipping test\n");
info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecc_public_key, 0);
ok(!!info, "got error %#lx.\n", GetLastError());
ok(!strcmp(info->pszOID, oid_ecc_public_key), "got %s.\n", info->pszOID);
ok(!wcscmp(info->pwszName, L"ECC"), "got %s.\n", wine_dbgstr_w(info->pwszName));
ok(info->dwGroupId == CRYPT_PUBKEY_ALG_OID_GROUP_ID, "got %lu.\n", info->dwGroupId);
ok(info->Algid == CALG_OID_INFO_PARAMETERS, "got %d.\n", info->Algid);
ok(!info->ExtraInfo.cbData, "got %ld.\n", info->ExtraInfo.cbData);
ok(!wcscmp(info->pwszCNGAlgid, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), "got %s.\n", wine_dbgstr_w(info->pwszCNGAlgid));
ok(info->pwszCNGExtraAlgid && !wcscmp(info->pwszCNGExtraAlgid, L""), "got %s.\n",
wine_dbgstr_w(info->pwszCNGExtraAlgid));
}
static void test_registerOIDInfo(void)
{
static const WCHAR winetestW[] = { 'w','i','n','e','t','e','s','t',0 };
static char test_oid[] = "1.2.3.4.5.6.7.8.9.10";
CRYPT_OID_INFO info1;
const CRYPT_OID_INFO *info2;
@@ -628,25 +600,26 @@ static void test_registerOIDInfo(void)
SetLastError(0xdeadbeef);
ret = CryptUnregisterOIDInfo(NULL);
ok(!ret, "should fail\n");
ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
memset(&info1, 0, sizeof(info1));
SetLastError(0xdeadbeef);
ret = CryptUnregisterOIDInfo(&info1);
ok(!ret, "should fail\n");
ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
info1.cbSize = sizeof(info1);
SetLastError(0xdeadbeef);
ret = CryptUnregisterOIDInfo(&info1);
ok(!ret, "should fail\n");
ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
info1.pszOID = test_oid;
SetLastError(0xdeadbeef);
ret = CryptUnregisterOIDInfo(&info1);
ok(!ret, "should fail\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got %u\n", GetLastError());
ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED, "got %lu\n", GetLastError());
info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0);
ok(!info2, "should fail\n");
@@ -656,15 +629,15 @@ static void test_registerOIDInfo(void)
* registry on Windows because dwGroupId == 0.
*/
ret = CryptRegisterOIDInfo(&info1, 0);
ok(ret, "got %u\n", GetLastError());
ok(ret, "got %lu\n", GetLastError());
ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret);
ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret);
info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0);
ok(!info2, "should fail\n");
info1.pwszName = winetestW;
info1.pwszName = L"winetest";
info1.dwGroupId = CRYPT_HASH_ALG_OID_GROUP_ID;
SetLastError(0xdeadbeef);
ret = CryptRegisterOIDInfo(&info1, CRYPT_INSTALL_OID_INFO_BEFORE_FLAG);
@@ -673,7 +646,7 @@ static void test_registerOIDInfo(void)
skip("Need admin rights\n");
return;
}
ok(ret, "got %u\n", GetLastError());
ok(ret, "got %lu\n", GetLastError());
/* It looks like crypt32 reads the OID info from registry only on load,
* and CryptFindOIDInfo will find the registered OID on next run
@@ -682,38 +655,38 @@ static void test_registerOIDInfo(void)
ok(!info2, "should fail\n");
ret = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
ok(!ret, "got %u\n", ret);
ok(!ret, "got %lu\n", ret);
memset(buf, 0, sizeof(buf));
size = sizeof(buf);
ret = RegQueryValueExA(key, "Name", NULL, &type, (BYTE *)buf, &size);
ok(!ret, "got %u\n", ret);
ok(type == REG_SZ, "got %u\n", type);
ok(!ret, "got %lu\n", ret);
ok(type == REG_SZ, "got %lu\n", type);
ok(!strcmp(buf, "winetest"), "got %s\n", buf);
value = 0xdeadbeef;
size = sizeof(value);
ret = RegQueryValueExA(key, "Flags", NULL, &type, (BYTE *)&value, &size);
ok(!ret, "got %u\n", ret);
ok(type == REG_DWORD, "got %u\n", type);
ok(value == 1, "got %u\n", value);
ok(!ret, "got %lu\n", ret);
ok(type == REG_DWORD, "got %lu\n", type);
ok(value == 1, "got %lu\n", value);
RegCloseKey(key);
CryptUnregisterOIDInfo(&info1);
ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret);
ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret);
}
START_TEST(oid)
{
HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll");
pCryptEnumOIDInfo = (void*)GetProcAddress(hCrypt32, "CryptEnumOIDInfo");
testOIDToAlgID();
testAlgIDToOID();
test_OIDToAlgID();
test_AlgIDToOID();
test_enumOIDInfo();
#ifdef __REACTOS__
if ((GetVersion() & 0xFF) > 5) // test_findOIDInfo() crashes on Server 2003
#endif
test_findOIDInfo();
test_registerOIDInfo();
test_oidFunctionSet();
@@ -27,13 +27,9 @@
#include "wine/test.h"
static BOOL (WINAPI *pCryptProtectData)(DATA_BLOB*,LPCWSTR,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*);
static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*);
static char secret[] = "I am a super secret string that no one can see!";
static char secret2[] = "I am a super secret string indescribable string";
static char key[] = "Wibble wibble wibble";
static const WCHAR desc[] = {'U','l','t','r','a',' ','s','e','c','r','e','t',' ','t','e','s','t',' ','m','e','s','s','a','g','e',0};
static BOOL protected = FALSE; /* if true, the unprotect tests can run */
static DATA_BLOB cipher;
static DATA_BLOB cipher_entropy;
@@ -52,32 +48,28 @@ static void test_cryptprotectdata(void)
entropy.cbData=strlen(key)+1;
SetLastError(0xDEADBEEF);
protected = pCryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher);
protected = CryptProtectData(NULL, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher);
ok(!protected, "Encrypting without plain data source.\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
SetLastError(0xDEADBEEF);
protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL);
protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, NULL);
ok(!protected, "Encrypting without cipher destination.\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
cipher.pbData=NULL;
cipher.cbData=0;
/* without entropy */
SetLastError(0xDEADBEEF);
protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher);
ok(protected ||
broken(!protected), /* Win9x/NT4 */
"Encrypting without entropy.\n");
protected = CryptProtectData(&plain, L"Ultra secret test message", NULL, NULL, NULL, 0, &cipher);
ok(protected, "Encrypting without entropy.\n");
if (protected)
{
r = GetLastError();
ok(r == ERROR_SUCCESS ||
r == ERROR_IO_PENDING, /* win2k */
"Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %d\n",r);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n",r);
}
cipher_entropy.pbData=NULL;
@@ -85,10 +77,8 @@ static void test_cryptprotectdata(void)
/* with entropy */
SetLastError(0xDEADBEEF);
protected = pCryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy);
ok(protected ||
broken(!protected), /* Win9x/NT4 */
"Encrypting with entropy.\n");
protected = CryptProtectData(&plain, L"Ultra secret test message", &entropy, NULL, NULL, 0, &cipher_entropy);
ok(protected, "Encrypting with entropy.\n");
cipher_no_desc.pbData=NULL;
cipher_no_desc.cbData=0;
@@ -97,13 +87,8 @@ static void test_cryptprotectdata(void)
plain.pbData=(void*)secret2;
plain.cbData=strlen(secret2)+1;
SetLastError(0xDEADBEEF);
protected = pCryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc);
if (!protected)
{
/* fails in win2k */
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
protected = CryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc);
ok(protected, "Encrypting with entropy.\n");
}
static void test_cryptunprotectdata(void)
@@ -117,36 +102,29 @@ static void test_cryptunprotectdata(void)
entropy.pbData=(void*)key;
entropy.cbData=strlen(key)+1;
/* fails in win2k */
if (!protected)
{
skip("CryptProtectData failed to run\n");
return;
}
plain.pbData=NULL;
plain.cbData=0;
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL);
okay = CryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL);
ok(!okay,"Decrypting without destination\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain);
okay = CryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain);
ok(!okay,"Decrypting without source\n");
r = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
plain.pbData=NULL;
plain.cbData=0;
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain);
okay = CryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain);
ok(!okay,"Decrypting without needed entropy\n");
r = GetLastError();
ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n", r);
ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n", r);
plain.pbData=NULL;
plain.cbData=0;
@@ -154,14 +132,14 @@ static void test_cryptunprotectdata(void)
/* without entropy */
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain);
okay = CryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain);
ok(okay,"Decrypting without entropy\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n");
ok(data_desc!=NULL,"Description not allocated\n");
ok(!lstrcmpW(data_desc,desc),"Description does not match\n");
ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n");
LocalFree(plain.pbData);
LocalFree(data_desc);
@@ -172,21 +150,21 @@ static void test_cryptunprotectdata(void)
/* with wrong entropy */
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain);
okay = CryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain);
ok(!okay,"Decrypting with wrong entropy\n");
r = GetLastError();
ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n",r);
ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n",r);
/* with entropy */
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain);
okay = CryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
ok(!strcmp((const char*)plain.pbData,secret),"Plain does not match secret\n");
ok(data_desc!=NULL,"Description not allocated\n");
ok(!lstrcmpW(data_desc,desc),"Description does not match\n");
ok(!lstrcmpW(data_desc, L"Ultra secret test message"),"Description does not match\n");
LocalFree(plain.pbData);
LocalFree(data_desc);
@@ -197,7 +175,7 @@ static void test_cryptunprotectdata(void)
/* with entropy but no description */
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain);
okay = CryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy and no description\n");
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
@@ -224,18 +202,12 @@ static void test_simpleroundtrip(const char *plaintext)
emptyW[0] = 0;
input.pbData = (unsigned char *)plaintext;
input.cbData = strlen(plaintext);
res = pCryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted);
ok(res != 0 || broken(!res), "can't protect\n");
if (!res)
{
/* Fails on Win9x, NT4 */
win_skip("CryptProtectData failed\n");
return;
}
res = CryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted);
ok(res != 0, "can't protect\n");
res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output);
ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext));
res = CryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output);
ok(res != 0, "can't unprotect; last error %lu\n", GetLastError());
ok(output.cbData == strlen(plaintext), "output wrong length %ld for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext));
ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext);
LocalFree(output.pbData);
LocalFree(encrypted.pbData);
@@ -243,16 +215,7 @@ static void test_simpleroundtrip(const char *plaintext)
START_TEST(protectdata)
{
HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll");
pCryptProtectData = (void*)GetProcAddress(hCrypt32, "CryptProtectData");
pCryptUnprotectData = (void*)GetProcAddress(hCrypt32, "CryptUnprotectData");
if (!pCryptProtectData || !pCryptUnprotectData)
{
win_skip("Crypt(Un)ProtectData() is not available\n");
return;
}
protected=FALSE;
protected = FALSE;
test_cryptprotectdata();
test_cryptunprotectdata();
test_simpleroundtrip("");
+39 -65
View File
@@ -41,15 +41,13 @@ static void test_AddRemoveProvider(void)
BOOL ret;
SIP_ADD_NEWPROVIDER newprov;
GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }};
static WCHAR dummydll[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 };
static WCHAR dummyfunction[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 };
/* NULL check */
SetLastError(0xdeadbeef);
ret = CryptSIPRemoveProvider(NULL);
ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
ok (GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
/* nonexistent provider should result in a registry error */
SetLastError(0xdeadbeef);
@@ -59,17 +57,6 @@ static void test_AddRemoveProvider(void)
/* Apparently the needed rights are checked before the existence of the provider */
skip("Need admin rights\n");
}
else
{
/* On some Win98 systems, CryptSIPRemoveProvider always succeeds if
* the arguments are correct, whether or not the registry key is
* present, so don't test ret, just check the last error if it does
* return FALSE.
*/
if (!ret)
ok (GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
}
/* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL
* as allowed */
@@ -77,12 +64,12 @@ static void test_AddRemoveProvider(void)
memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
newprov.pgSubject = &actionid;
newprov.pwszDLLFileName = dummydll;
newprov.pwszGetFuncName = dummyfunction;
newprov.pwszPutFuncName = dummyfunction;
newprov.pwszCreateFuncName = dummyfunction;
newprov.pwszVerifyFuncName = dummyfunction;
newprov.pwszRemoveFuncName = dummyfunction;
newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll";
newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction";
SetLastError(0xdeadbeef);
ret = CryptSIPAddProvider(&newprov);
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
@@ -90,7 +77,7 @@ static void test_AddRemoveProvider(void)
skip("Need admin rights\n");
return;
}
ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError());
ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
/* Dummy provider will be deleted, but the function still fails because
* pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the
@@ -98,38 +85,32 @@ static void test_AddRemoveProvider(void)
*/
SetLastError(0xdeadbeef);
ret = CryptSIPRemoveProvider(&actionid);
/* On some Win98 systems, CryptSIPRemoveProvider always succeeds if
* the arguments are correct, whether or not the registry key is
* present, so don't test ret, just check the last error if it does
* return FALSE.
*/
if (!ret)
ok (GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError());
/* Everything OK */
memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
newprov.pgSubject = &actionid;
newprov.pwszDLLFileName = dummydll;
newprov.pwszGetFuncName = dummyfunction;
newprov.pwszPutFuncName = dummyfunction;
newprov.pwszCreateFuncName = dummyfunction;
newprov.pwszVerifyFuncName = dummyfunction;
newprov.pwszRemoveFuncName = dummyfunction;
newprov.pwszIsFunctionNameFmt2 = dummyfunction;
newprov.pwszIsFunctionName = dummyfunction;
newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll";
newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction";
newprov.pwszIsFunctionNameFmt2 = (WCHAR *)L"dummyfunction";
newprov.pwszIsFunctionName = (WCHAR *)L"dummyfunction";
/* If GetCapFuncName set to NULL, then CryptSIPRemoveProvider fails on win 8 */
newprov.pwszGetCapFuncName = dummyfunction;
newprov.pwszGetCapFuncName = (WCHAR *)L"dummyfunction";
SetLastError(0xdeadbeef);
ret = CryptSIPAddProvider(&newprov);
ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError());
ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
/* Dummy provider should be deleted */
SetLastError(0xdeadbeef);
ret = CryptSIPRemoveProvider(&actionid);
ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %d\n", GetLastError());
ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %ld\n", GetLastError());
}
static const BYTE cabFileData[] = {
@@ -148,7 +129,6 @@ static void test_SIPRetrieveSubjectGUID(void)
static const CHAR windir[] = "windir";
static const CHAR regeditExe[] = "regedit.exe";
static const GUID nullSubject = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }};
static const WCHAR deadbeef[] = { 'c',':','\\','d','e','a','d','b','e','e','f','.','d','b','f',0 };
/* Couldn't find a name for this GUID, it's the one used for 95% of the files */
static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }};
@@ -164,17 +144,17 @@ static void test_SIPRetrieveSubjectGUID(void)
ret = CryptSIPRetrieveSubjectGuid(NULL, NULL, NULL);
ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
ok (GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
/* Test with a nonexistent file (hopefully) */
SetLastError(0xdeadbeef);
/* Set subject to something other than zeros */
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(deadbeef, NULL, &subject);
ret = CryptSIPRetrieveSubjectGuid(L"c:\\deadbeef.dbf", NULL, &subject);
ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
ok (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_PATH_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %d.\n",
"Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %ld.\n",
GetLastError());
ok(IsEqualGUID(&subject, &nullSubject),
"Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", wine_dbgstr_guid(&subject));
@@ -184,7 +164,7 @@ static void test_SIPRetrieveSubjectGUID(void)
* Use A-functions where possible as that should be available on all platforms
*/
ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH);
ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError());
ok (ret > 0, "expected GEVA(windir) to succeed, last error %ld\n", GetLastError());
strcat(regeditPath, "\\");
strcat(regeditPath, regeditExe);
MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW,
@@ -226,11 +206,8 @@ static void test_SIPRetrieveSubjectGUID(void)
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
ok ( GetLastError() == ERROR_FILE_INVALID ||
GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ ||
GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
"Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
ok ( GetLastError() == ERROR_FILE_INVALID || GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
ok(IsEqualGUID(&subject, &nullSubject),
"Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
@@ -243,10 +220,8 @@ static void test_SIPRetrieveSubjectGUID(void)
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
ok ( GetLastError() == ERROR_INVALID_PARAMETER ||
GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
"Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
ok(IsEqualGUID(&subject, &nullSubject),
"Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
@@ -259,9 +234,8 @@ static void test_SIPRetrieveSubjectGUID(void)
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN ||
GetLastError() == ERROR_SUCCESS /* Win98 */,
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN,
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08lx\n", GetLastError());
ok(IsEqualGUID(&subject, &nullSubject),
"Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
@@ -271,14 +245,14 @@ static void test_SIPRetrieveSubjectGUID(void)
/* Create a file with just the .cab header 'MSCF' */
SetLastError(0xdeadbeef);
file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
WriteFile(file, cabFileData, 4, &written, NULL);
CloseHandle(file);
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
GetLastError(), GetLastError() );
ok(IsEqualGUID(&subject, &cabGUID),
"Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
@@ -289,14 +263,14 @@ static void test_SIPRetrieveSubjectGUID(void)
/* Create a .cab file */
SetLastError(0xdeadbeef);
file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
WriteFile(file, cabFileData, sizeof(cabFileData), &written, NULL);
CloseHandle(file);
SetLastError(0xdeadbeef);
memset(&subject, 1, sizeof(GUID));
ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
GetLastError(), GetLastError() );
ok(IsEqualGUID(&subject, &cabGUID),
"Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
@@ -322,14 +296,14 @@ static void test_SIPLoad(void)
ret = CryptSIPLoad(NULL, 0, NULL);
ok ( !ret, "Expected CryptSIPLoad to fail\n");
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
/* Only pSipDispatch NULL */
SetLastError(0xdeadbeef);
ret = CryptSIPLoad(&subject, 0, NULL);
ok ( !ret, "Expected CryptSIPLoad to fail\n");
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
/* No NULLs, but nonexistent pgSubject */
SetLastError(0xdeadbeef);
@@ -339,7 +313,7 @@ static void test_SIPLoad(void)
ret = CryptSIPLoad(&dummySubject, 0, &sdi);
ok ( !ret, "Expected CryptSIPLoad to fail\n");
ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN,
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError());
ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
hCrypt = GetModuleHandleA("crypt32.dll");
@@ -430,7 +404,7 @@ static void test_SIPLoad(void)
ret = CryptSIPLoad(&unknown, 1, &sdi);
ok ( !ret, "Expected CryptSIPLoad to fail\n");
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
"Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff