Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/rsaenh/tests/Makefile.in | 1 dlls/rsaenh/tests/rsaenh.c | 1014 +++++++++++++++++++++-------------------- 2 files changed, 507 insertions(+), 508 deletions(-)
diff --git a/dlls/rsaenh/tests/Makefile.in b/dlls/rsaenh/tests/Makefile.in index 641a3fff080..91f2d28ef6d 100644 --- a/dlls/rsaenh/tests/Makefile.in +++ b/dlls/rsaenh/tests/Makefile.in @@ -1,4 +1,3 @@ -EXTRADEFS = -DWINE_NO_LONG_TYPES TESTDLL = rsaenh.dll IMPORTS = advapi32
diff --git a/dlls/rsaenh/tests/rsaenh.c b/dlls/rsaenh/tests/rsaenh.c index 30399714741..f822c29bbc0 100644 --- a/dlls/rsaenh/tests/rsaenh.c +++ b/dlls/rsaenh/tests/rsaenh.c @@ -140,14 +140,14 @@ static BOOL init_base_environment(const char *provider, DWORD dwKeyFlags) result = CryptAcquireContextA(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(!result && (GetLastError()==NTE_BAD_FLAGS || broken(GetLastError() == NTE_KEYSET_NOT_DEF /* Win9x/NT4 */)), - "%d, %08x\n", result, GetLastError()); + "%d, %08lx\n", result, GetLastError());
if (!CryptAcquireContextA(&hProv, szContainer, szProvider, PROV_RSA_FULL, 0)) { ok(GetLastError()==NTE_BAD_KEYSET || broken(GetLastError() == NTE_TEMPORARY_PROFILE /* some Win7 setups */) || broken(GetLastError() == NTE_KEYSET_NOT_DEF /* Win9x/NT4 */), - "%08x\n", GetLastError()); + "%08lx\n", GetLastError()); if (GetLastError()!=NTE_BAD_KEYSET) { win_skip("RSA full provider not available\n"); @@ -155,17 +155,17 @@ static BOOL init_base_environment(const char *provider, DWORD dwKeyFlags) } result = CryptAcquireContextA(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) { win_skip("Couldn't create crypto provider\n"); return FALSE; } result = CryptGenKey(hProv, AT_KEYEXCHANGE, dwKeyFlags, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey); result = CryptGenKey(hProv, AT_SIGNATURE, dwKeyFlags, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey); } return TRUE; @@ -178,12 +178,12 @@ static void clean_up_base_environment(void) SetLastError(0xdeadbeef); result = CryptReleaseContext(hProv, 1); ok(!result || broken(result) /* Win98 */, "Expected failure\n"); - ok(GetLastError()==NTE_BAD_FLAGS, "Expected NTE_BAD_FLAGS, got %08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_FLAGS, "Expected NTE_BAD_FLAGS, got %08lx\n", GetLastError());
/* Just to prove that Win98 also released the CSP */ SetLastError(0xdeadbeef); result = CryptReleaseContext(hProv, 0); - ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "%08x\n", GetLastError()); + ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "%08lx\n", GetLastError());
CryptAcquireContextA(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } @@ -208,30 +208,30 @@ static BOOL init_aes_environment(void) win_skip("RSA_AES provider not supported\n"); return FALSE; } - ok(!result && GetLastError()==NTE_BAD_FLAGS, "%d, %08x\n", result, GetLastError()); + ok(!result && GetLastError()==NTE_BAD_FLAGS, "%d, %08lx\n", result, GetLastError());
if (!CryptAcquireContextA(&hProv, szContainer, NULL, PROV_RSA_AES, 0)) { - ok(GetLastError()==NTE_BAD_KEYSET, "%08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_KEYSET, "%08lx\n", GetLastError()); if (GetLastError()!=NTE_BAD_KEYSET) return FALSE; result = CryptAcquireContextA(&hProv, szContainer, NULL, PROV_RSA_AES, CRYPT_NEWKEYSET); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return FALSE; result = CryptGenKey(hProv, AT_KEYEXCHANGE, 0, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey); result = CryptGenKey(hProv, AT_SIGNATURE, 0, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey);
/* CALG_AES is not supported, but CALG_AES_128 is */ result = CryptGenKey(hProv, CALG_AES, 0, &hKey); - ok(!result && GetLastError() == NTE_BAD_ALGID, "%d %08x\n", result, GetLastError()); + ok(!result && GetLastError() == NTE_BAD_ALGID, "%d %08lx\n", result, GetLastError()); result = CryptGenKey(hProv, CALG_AES, 128 << 16, &hKey); - ok(!result && GetLastError() == NTE_BAD_ALGID, "%d %08x\n", result, GetLastError()); + ok(!result && GetLastError() == NTE_BAD_ALGID, "%d %08lx\n", result, GetLastError()); result = CryptGenKey(hProv, CALG_AES_128, 0, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey); } return TRUE; @@ -242,7 +242,7 @@ static void clean_up_aes_environment(void) BOOL result;
result = CryptReleaseContext(hProv, 1); - ok(!result && GetLastError()==NTE_BAD_FLAGS, "%08x\n", GetLastError()); + ok(!result && GetLastError()==NTE_BAD_FLAGS, "%08lx\n", GetLastError());
CryptAcquireContextA(&hProv, szContainer, NULL, PROV_RSA_AES, CRYPT_DELETEKEYSET); } @@ -261,7 +261,7 @@ static void test_prov(void) nt4++; } else - ok(result && dwInc==8, "%08x, %d\n", GetLastError(), dwInc); + ok(result && dwInc==8, "%08lx, %ld\n", GetLastError(), dwInc);
dwLen = (DWORD)sizeof(DWORD); SetLastError(0xdeadbeef); @@ -269,7 +269,7 @@ static void test_prov(void) if (!result && GetLastError() == NTE_BAD_TYPE) skip("PP_KEYX_KEYSIZE_INC is not supported (win9x or NT)\n"); else - ok(result && dwInc==8, "%08x, %d\n", GetLastError(), dwInc); + ok(result && dwInc==8, "%08lx, %ld\n", GetLastError(), dwInc); }
static void test_gen_random(void) @@ -286,10 +286,10 @@ static void test_gen_random(void) return; }
- ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptGenRandom(hProv, sizeof(rnd2), rnd2); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(memcmp(rnd1, rnd2, sizeof(rnd1)), "CryptGenRandom generates non random data\n"); } @@ -306,19 +306,19 @@ static BOOL derive_key(ALG_ID aiAlgid, HCRYPTKEY *phKey, DWORD len) result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError()==NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_ALGID, "%08lx\n", GetLastError()); return FALSE; } - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return FALSE; result = CryptDeriveKey(hProv, aiAlgid, hHash, (len << 16) | CRYPT_EXPORTABLE, phKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return FALSE; len = 2000; result = CryptGetHashParam(hHash, HP_HASHVAL, pbData, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); CryptDestroyHash(hHash); return TRUE; } @@ -445,31 +445,31 @@ static void test_hashes(void) result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError() == NTE_BAD_ALGID, "%08lx\n", GetLastError()); } else { result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 16), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 16), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
len = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, md2hash, 16), "Wrong MD2 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
/* MD4 Hashing */ result = CryptCreateHash(hProv, CALG_MD4, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHash, pbData, sizeof(pbData), ~0); - ok(!result && GetLastError() == NTE_BAD_FLAGS, "%08x\n", GetLastError()); + ok(!result && GetLastError() == NTE_BAD_FLAGS, "%08lx\n", GetLastError());
cryptflags = CRYPT_USERDATA; result = CryptHashData(hHash, pbData, sizeof(pbData), cryptflags); @@ -479,57 +479,57 @@ static void test_hashes(void) ok(broken(1), "Failed to support CRYPT_USERDATA flag\n"); result = CryptHashData(hHash, pbData, sizeof(pbData), 0); } - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 16), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 16), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
len = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, md4hash, 16), "Wrong MD4 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* MD5 Hashing */ result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 16), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 16), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), ~0); - ok(!result && GetLastError() == NTE_BAD_FLAGS, "%08x\n", GetLastError()); + ok(!result && GetLastError() == NTE_BAD_FLAGS, "%08lx\n", GetLastError());
result = CryptHashData(hHash, pbData, sizeof(pbData), cryptflags); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, md5hash, 16), "Wrong MD5 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* The hash is available even if CryptHashData hasn't been called */ len = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, empty_md5hash, 16), "Wrong MD5 hash!\n");
/* It's also stable: getting it twice results in the same value */ result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, empty_md5hash, 16), "Wrong MD5 hash!\n");
@@ -539,80 +539,80 @@ static void test_hashes(void) ok(!result, "Expected failure\n"); ok(GetLastError() == NTE_BAD_HASH_STATE || GetLastError() == NTE_BAD_ALGID, /* Win9x, WinMe, NT4 */ - "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID, got %08x\n", GetLastError()); + "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID, got %08lx\n", GetLastError());
/* You can still retrieve the hash, its value just hasn't changed */ result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, empty_md5hash, 16), "Wrong MD5 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* SHA1 Hashing */ result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHash, pbData, 5, cryptflags); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
if(pCryptDuplicateHash) { result = pCryptDuplicateHash(hHash, 0, 0, &hHashClone); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHashClone, (BYTE*)pbData+5, sizeof(pbData)-5, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = sizeof(DWORD); result = CryptGetHashParam(hHashClone, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 20), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 20), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
len = 20; result = CryptGetHashParam(hHashClone, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, sha1hash, 20), "Wrong SHA1 hash!\n");
result = CryptDestroyHash(hHashClone); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* The SHA-2 variants aren't supported in the RSA full provider */ result = CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash); ok(!result && GetLastError() == NTE_BAD_ALGID, - "expected NTE_BAD_ALGID, got %08x\n", GetLastError()); + "expected NTE_BAD_ALGID, got %08lx\n", GetLastError()); result = CryptCreateHash(hProv, CALG_SHA_384, 0, 0, &hHash); ok(!result && GetLastError() == NTE_BAD_ALGID, - "expected NTE_BAD_ALGID, got %08x\n", GetLastError()); + "expected NTE_BAD_ALGID, got %08lx\n", GetLastError()); result = CryptCreateHash(hProv, CALG_SHA_512, 0, 0, &hHash); ok(!result && GetLastError() == NTE_BAD_ALGID, - "expected NTE_BAD_ALGID, got %08x\n", GetLastError()); + "expected NTE_BAD_ALGID, got %08lx\n", GetLastError());
result = CryptAcquireContextA(&prov, NULL, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(result, "CryptAcquireContextA failed 0x%08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed 0x%08lx\n", GetLastError());
result = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hHash); - ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptCreateHash failed 0x%08lx\n", GetLastError());
/* release provider before using the hash */ result = CryptReleaseContext(prov, 0); - ok(result, "CryptReleaseContext failed 0x%08x\n", GetLastError()); + ok(result, "CryptReleaseContext failed 0x%08lx\n", GetLastError());
SetLastError(0xdeadbeef); result = CryptHashData(hHash, (const BYTE *)"data", sizeof("data"), 0); error = GetLastError(); ok(!result, "CryptHashData succeeded\n"); - ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error); + ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", error);
SetLastError(0xdeadbeef); result = CryptDestroyHash(hHash); error = GetLastError(); ok(!result, "CryptDestroyHash succeeded\n"); - ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error); + ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", error);
if (!pCryptDuplicateHash) { @@ -621,76 +621,76 @@ static void test_hashes(void) }
result = CryptAcquireContextA(&prov, NULL, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(result, "CryptAcquireContextA failed 0x%08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed 0x%08lx\n", GetLastError());
result = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash); - ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptCreateHash failed 0x%08lx\n", GetLastError());
result = CryptHashData(hHash, (const BYTE *)"data", sizeof("data"), 0); - ok(result, "CryptHashData failed 0x%08x\n", GetLastError()); + ok(result, "CryptHashData failed 0x%08lx\n", GetLastError());
result = pCryptDuplicateHash(hHash, NULL, 0, &hHashClone); - ok(result, "CryptDuplicateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDuplicateHash failed 0x%08lx\n", GetLastError());
len = 20; result = CryptGetHashParam(hHashClone, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "CryptGetHashParam failed 0x%08x\n", GetLastError()); + ok(result, "CryptGetHashParam failed 0x%08lx\n", GetLastError());
/* add data after duplicating the hash */ result = CryptHashData(hHash, (const BYTE *)"more data", sizeof("more data"), 0); - ok(result, "CryptHashData failed 0x%08x\n", GetLastError()); + ok(result, "CryptHashData failed 0x%08lx\n", GetLastError());
result = CryptDestroyHash(hHash); - ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyHash failed 0x%08lx\n", GetLastError());
result = CryptDestroyHash(hHashClone); - ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyHash failed 0x%08lx\n", GetLastError());
result = CryptReleaseContext(prov, 0); - ok(result, "CryptReleaseContext failed 0x%08x\n", GetLastError()); + ok(result, "CryptReleaseContext failed 0x%08lx\n", GetLastError());
/* Test CALG_SSL3_SHAMD5 */ result = CryptAcquireContextA(&prov, NULL, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(result, "CryptAcquireContextA failed 0x%08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed 0x%08lx\n", GetLastError());
/* Step 1: create an MD5 hash of the data */ result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptCreateHash failed 0x%08lx\n", GetLastError()); result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); len = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "CryptGetHashParam failed 0x%08x\n", GetLastError()); + ok(result, "CryptGetHashParam failed 0x%08lx\n", GetLastError()); result = CryptDestroyHash(hHash); - ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyHash failed 0x%08lx\n", GetLastError()); /* Step 2: create a SHA1 hash of the data */ result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash); - ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptCreateHash failed 0x%08lx\n", GetLastError()); result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); len = 20; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue + 16, &len, 0); - ok(result, "CryptGetHashParam failed 0x%08x\n", GetLastError()); + ok(result, "CryptGetHashParam failed 0x%08lx\n", GetLastError()); result = CryptDestroyHash(hHash); - ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyHash failed 0x%08lx\n", GetLastError()); /* Step 3: create a CALG_SSL3_SHAMD5 hash handle */ result = CryptCreateHash(hProv, CALG_SSL3_SHAMD5, 0, 0, &hHash); - ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptCreateHash failed 0x%08lx\n", GetLastError()); /* Test that CryptHashData fails on this hash */ result = CryptHashData(hHash, pbData, sizeof(pbData), 0); ok(!result && (GetLastError() == NTE_BAD_ALGID || broken(GetLastError() == ERROR_INVALID_HANDLE)) /* Win 8 */, - "%08x\n", GetLastError()); + "%08lx\n", GetLastError()); result = CryptSetHashParam(hHash, HP_HASHVAL, pbHashValue, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); len = (DWORD)sizeof(abPlainPrivateKey); result = CryptImportKey(hProv, abPlainPrivateKey, len, 0, 0, &hKeyExchangeKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); len = 0; result = CryptSignHashA(hHash, AT_KEYEXCHANGE, NULL, 0, NULL, &len); - ok(result, "%08x\n", GetLastError()); - ok(len == 128, "expected len 128, got %d\n", len); + ok(result, "%08lx\n", GetLastError()); + ok(len == 128, "expected len 128, got %ld\n", len); result = CryptSignHashA(hHash, AT_KEYEXCHANGE, NULL, 0, pbSigValue, &len); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(!memcmp(pbSigValue, signed_ssl3_shamd5_hash, len), "unexpected value\n"); if (len != 128 || memcmp(pbSigValue, signed_ssl3_shamd5_hash, len)) { @@ -699,11 +699,11 @@ static void test_hashes(void) printBytes("got", pbSigValue, len); } result = CryptDestroyKey(hKeyExchangeKey); - ok(result, "CryptDestroyKey failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyKey failed 0x%08lx\n", GetLastError()); result = CryptDestroyHash(hHash); - ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError()); + ok(result, "CryptDestroyHash failed 0x%08lx\n", GetLastError()); result = CryptReleaseContext(prov, 0); - ok(result, "CryptReleaseContext failed 0x%08x\n", GetLastError()); + ok(result, "CryptReleaseContext failed 0x%08lx\n", GetLastError()); }
static void test_block_cipher_modes(void) @@ -734,71 +734,71 @@ static void test_block_cipher_modes(void) dwMode = 0xdeadbeef; dwLen = sizeof(dwMode); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwMode == CRYPT_MODE_CBC, "Wrong default chaining mode\n");
dwMode = CRYPT_MODE_ECB; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == 11 || broken(dwLen == 0 /* Win9x/NT4 */), "unexpected salt length %d\n", dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == 11 || broken(dwLen == 0 /* Win9x/NT4 */), "unexpected salt length %ld\n", dwLen);
dwLen = 23; result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwLen, 24); - ok(result, "CryptEncrypt failed: %08x\n", GetLastError()); - ok(dwLen == 24, "Unexpected length %d\n", dwLen); + ok(result, "CryptEncrypt failed: %08lx\n", GetLastError()); + ok(dwLen == 24, "Unexpected length %ld\n", dwLen);
SetLastError(ERROR_SUCCESS); dwLen = 23; result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); ok(result && dwLen == 24 && !memcmp(ecb, abData, sizeof(ecb)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
result = CryptDecrypt(hKey, 0, TRUE, 0, abData, &dwLen); ok(result && dwLen == 23 && !memcmp(plain, abData, sizeof(plain)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwMode = CRYPT_MODE_CBC; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 23; result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwLen, 24); - ok(result, "CryptEncrypt failed: %08x\n", GetLastError()); - ok(dwLen == 24, "Unexpected length %d\n", dwLen); + ok(result, "CryptEncrypt failed: %08lx\n", GetLastError()); + ok(dwLen == 24, "Unexpected length %ld\n", dwLen);
dwLen = 23; result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); ok(result && dwLen == 24 && !memcmp(cbc, abData, sizeof(cbc)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
result = CryptDecrypt(hKey, 0, TRUE, 0, abData, &dwLen); ok(result && dwLen == 23 && !memcmp(plain, abData, sizeof(plain)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwMode = CRYPT_MODE_CFB; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 16; result = CryptEncrypt(hKey, 0, FALSE, 0, abData, &dwLen, 24); - ok(result && dwLen == 16, "%08x, dwLen: %d\n", GetLastError(), dwLen); + ok(result && dwLen == 16, "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwLen = 7; result = CryptEncrypt(hKey, 0, TRUE, 0, abData+16, &dwLen, 8); ok(result && dwLen == 8 && !memcmp(cfb, abData, sizeof(cfb)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwLen = 8; result = CryptDecrypt(hKey, 0, FALSE, 0, abData, &dwLen); - ok(result && dwLen == 8, "%08x, dwLen: %d\n", GetLastError(), dwLen); + ok(result && dwLen == 8, "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwLen = 16; result = CryptDecrypt(hKey, 0, TRUE, 0, abData+8, &dwLen); ok(result && dwLen == 15 && !memcmp(plain, abData, sizeof(plain)), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
dwMode = CRYPT_MODE_OFB; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); @@ -808,11 +808,11 @@ static void test_block_cipher_modes(void) } else { - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 23; result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); - ok(!result && GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(!result && GetLastError() == NTE_BAD_ALGID, "%08lx\n", GetLastError()); }
CryptDestroyKey(hKey); @@ -832,7 +832,7 @@ static void test_3des112(void) result = derive_key(CALG_3DES_112, &hKey, 0); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError() == NTE_BAD_ALGID, "%08lx\n", GetLastError()); return; }
@@ -840,12 +840,12 @@ static void test_3des112(void)
dwLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbData, des112, sizeof(des112)), "3DES_112 encryption failed!\n");
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
for (i=0; i<4; i++) { @@ -853,13 +853,13 @@ static void test_3des112(void)
dwLen = cTestData[i].enclen; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -877,7 +877,7 @@ static void test_3des112(void) dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Restoring key state by decrypting bad_data with Final = TRUE */ memcpy(bad_data, enc_data, cTestData[i].buflen); @@ -885,16 +885,16 @@ static void test_3des112(void) SetLastError(0xdeadbeef); result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen); ok(!result, "CryptDecrypt should failed!\n"); - ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(GetLastError() == NTE_BAD_DATA, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i);
/* Checking key state */ dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -904,7 +904,7 @@ static void test_3des112(void) } } result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
static void test_des(void) @@ -927,29 +927,29 @@ static void test_des(void) result = derive_key(CALG_DES, &hKey, 0); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError()==NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_ALGID, "%08lx\n", GetLastError()); return; }
dwMode = CRYPT_MODE_ECB; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwMode == CRYPT_MODE_ECB, "Expected CRYPT_MODE_ECB, got %d\n", dwMode); + ok(result, "%08lx\n", GetLastError()); + ok(dwMode == CRYPT_MODE_ECB, "Expected CRYPT_MODE_ECB, got %ld\n", dwMode);
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
dwLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbData, des, sizeof(des)), "DES encryption failed!\n");
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
for (i=0; i<4; i++) { @@ -957,13 +957,13 @@ static void test_des(void)
dwLen = cTestData[i].enclen; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -981,7 +981,7 @@ static void test_des(void) dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Restoring key state by decrypting bad_data with Final = TRUE */ memcpy(bad_data, enc_data, cTestData[i].buflen); @@ -989,16 +989,16 @@ static void test_des(void) SetLastError(0xdeadbeef); result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen); ok(!result, "CryptDecrypt should failed!\n"); - ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(GetLastError() == NTE_BAD_DATA, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i);
/* Checking key state */ dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -1009,27 +1009,27 @@ static void test_des(void) }
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Windows >= XP changed the way DES keys are derived, this test ensures we don't break that */ derive_key(CALG_DES, &hKey, 56);
dwMode = CRYPT_MODE_ECB; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
dwLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(!memcmp(pbData, des, sizeof(des)) || broken( !memcmp(pbData, des_old_behavior, sizeof(des)) || (STRONG_PROV && !memcmp(pbData, des_old_strong, sizeof(des)))) /* <= 2000 */, "DES encryption failed!\n");
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
static void test_3des(void) @@ -1050,12 +1050,12 @@ static void test_3des(void)
dwLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbData, des3, sizeof(des3)), "3DES encryption failed!\n");
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
for (i=0; i<4; i++) { @@ -1063,13 +1063,13 @@ static void test_3des(void)
dwLen = cTestData[i].enclen; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -1087,7 +1087,7 @@ static void test_3des(void) dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Restoring key state by decrypting bad_data with Final = TRUE */ memcpy(bad_data, enc_data, cTestData[i].buflen); @@ -1095,16 +1095,16 @@ static void test_3des(void) SetLastError(0xdeadbeef); result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen); ok(!result, "CryptDecrypt should failed!\n"); - ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(GetLastError() == NTE_BAD_DATA, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i);
/* Checking key state */ dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -1114,7 +1114,7 @@ static void test_3des(void) } } result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
static void test_aes(int keylen) @@ -1161,36 +1161,36 @@ static void test_aes(int keylen) dwLen = sizeof(aes_plain); memcpy(pbData, aes_plain, dwLen); result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, sizeof(pbData)); - ok(result, "Expected OK, got last error %d\n", GetLastError()); - ok(dwLen == 48, "Expected dwLen 48, got %d\n", dwLen); + ok(result, "Expected OK, got last error %ld\n", GetLastError()); + ok(dwLen == 48, "Expected dwLen 48, got %ld\n", dwLen); ok(!memcmp(aes_cbc_enc[i], pbData, dwLen), "Expected equal data sequences\n");
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); ok(result && dwLen == 32 && !memcmp(aes_plain, pbData, dwLen), - "%08x, dwLen: %d\n", GetLastError(), dwLen); + "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
/* Does AES provider support salt? */ result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); todo_wine ok(result || broken(GetLastError() == NTE_BAD_KEY), /* Vista or older */ - "Expected OK, got last error %d\n", GetLastError()); + "Expected OK, got last error %ld\n", GetLastError()); if (result) - ok(!dwLen, "unexpected salt length %d\n", dwLen); + ok(!dwLen, "unexpected salt length %ld\n", dwLen);
/* test default chaining mode */ dwMode = 0xdeadbeef; dwLen = sizeof(dwMode); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwMode == CRYPT_MODE_CBC, "Wrong default chaining\n");
dwLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
for (i=0; i<4; i++) { @@ -1198,13 +1198,13 @@ static void test_aes(int keylen)
dwLen = cTestData[i].enclen; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -1222,7 +1222,7 @@ static void test_aes(int keylen) dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Restoring key state by decrypting bad_data with Final = TRUE */ memcpy(bad_data, enc_data, cTestData[i].buflen); @@ -1230,16 +1230,16 @@ static void test_aes(int keylen) SetLastError(0xdeadbeef); result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen); ok(!result, "CryptDecrypt should failed!\n"); - ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].buflen); + ok(GetLastError() == NTE_BAD_DATA, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].buflen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].buflen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i);
/* Checking key state */ dwLen = cTestData[i].buflen; memcpy(pbData, enc_data, cTestData[i].buflen); result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected %d\n",dwLen,cTestData[i].enclen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen==cTestData[i].enclen,"length incorrect, got %ld, expected %d\n",dwLen,cTestData[i].enclen); ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption incorrect %d\n",i); if((dwLen != cTestData[i].enclen) || memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen)) @@ -1249,7 +1249,7 @@ static void test_aes(int keylen) } } result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
static void test_sha2(void) @@ -1292,65 +1292,65 @@ static void test_sha2(void) win_skip("SHA-256/384/512 hashes are not supported before Windows XP SP3\n"); return; } - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) { len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 32), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 32), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = 32; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, sha256hash, 32), "Wrong SHA-256 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
/* SHA-384 hash */ result = CryptCreateHash(hProv, CALG_SHA_384, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) { len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 48), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 48), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = 48; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, sha384hash, 48), "Wrong SHA-384 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
/* SHA-512 hash */ result = CryptCreateHash(hProv, CALG_SHA_512, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (result) { len = sizeof(DWORD); result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); - ok(result && (hashlen == 64), "%08x, hashlen: %d\n", GetLastError(), hashlen); + ok(result && (hashlen == 64), "%08lx, hashlen: %ld\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
len = 64; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbHashValue, sha512hash, 64), "Wrong SHA-512 hash!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); } }
@@ -1389,130 +1389,130 @@ static void test_rc2(void) /* MD2 Hashing */ result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { - ok(GetLastError()==NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_ALGID, "%08lx\n", GetLastError()); } else { CRYPT_INTEGER_BLOB salt;
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDeriveKey(hProv, CALG_RC2, hHash, 40 << 16, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* test default chaining mode */ dwMode = 0xdeadbeef; dwLen = sizeof(dwMode); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwMode == CRYPT_MODE_CBC, "Wrong default chaining mode\n");
dwMode = CRYPT_MODE_CBC; result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_MODE_BITS, (BYTE*)&dwModeBits, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwModeBits = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_PERMISSIONS, (BYTE*)&dwModeBits, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwModeBits == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwModeBits == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwModeBits); + " got %08lx\n", dwModeBits);
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_PERMISSIONS, (BYTE*)&dwModeBits, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwModeBits, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == 4, "Expected 4, got %d\n", dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == 4, "Expected 4, got %ld\n", dwLen);
dwLen = 0; result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == 8, "Expected 8, got %d\n", dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == 8, "Expected 8, got %ld\n", dwLen);
dwLen = 0; result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); /* The default salt length is always 11... */ - ok(dwLen == 11, "unexpected salt length %d\n", dwLen); + ok(dwLen == 11, "unexpected salt length %ld\n", dwLen); /* and the default salt is always empty. */ result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); for (i=0; i<dwLen; i++) ok(!pszBuffer[i], "unexpected salt value %02x @ %d\n", pszBuffer[i], i);
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwMode == CRYPT_MODE_CBC, "Expected CRYPT_MODE_CBC, got %d\n", dwMode); + ok(result, "%08lx\n", GetLastError()); + ok(dwMode == CRYPT_MODE_CBC, "Expected CRYPT_MODE_CBC, got %ld\n", dwMode);
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwDataLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbData, rc2_40_encrypted, 16), "RC2 encryption failed!\n");
dwLen = 0; result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Setting the salt value will not reset the salt length in base or strong providers */ result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0); - ok(result, "setting salt failed: %08x\n", GetLastError()); + ok(result, "setting salt failed: %08lx\n", GetLastError()); dwLen = 0; result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (BASE_PROV || STRONG_PROV) - ok(dwLen == 11, "expected salt length 11, got %d\n", dwLen); + ok(dwLen == 11, "expected salt length 11, got %ld\n", dwLen); else - ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %d\n", dwLen); + ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %ld\n", dwLen); /* What sizes salt can I set? */ salt.pbData = pbData; for (i=0; i<24; i++) { salt.cbData = i; result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0); - ok(result, "setting salt failed for size %d: %08x\n", i, GetLastError()); + ok(result, "setting salt failed for size %d: %08lx\n", i, GetLastError()); /* The returned salt length is the same as the set salt length */ result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == i, "size %d: unexpected salt length %d\n", i, dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == i, "size %d: unexpected salt length %ld\n", i, dwLen); } salt.cbData = 25; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0); ok(!result || broken(result), /* Win9x, WinMe, NT4, W2K */ - "%08x\n", GetLastError()); + "%08lx\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
/* Again, but test setting the effective key len */ @@ -1520,37 +1520,37 @@ static void test_rc2(void)
result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { - ok(GetLastError()==NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError()==NTE_BAD_ALGID, "%08lx\n", GetLastError()); } else { result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDeriveKey(hProv, CALG_RC2, hHash, 56 << 16, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
SetLastError(0xdeadbeef); result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, NULL, 0); - ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "%08x\n", GetLastError()); + ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "%08lx\n", GetLastError()); dwKeyLen = 0; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (LPBYTE)&dwKeyLen, 0); - ok(!result && GetLastError()==NTE_BAD_DATA, "%08x\n", GetLastError()); + ok(!result && GetLastError()==NTE_BAD_DATA, "%08lx\n", GetLastError()); dwKeyLen = 1025; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (LPBYTE)&dwKeyLen, 0); - ok(!result, "CryptSetKeyParam failed: %08x\n", GetLastError()); + ok(!result, "CryptSetKeyParam failed: %08lx\n", GetLastError());
dwLen = sizeof(dwKeyLen); result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError()); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 56, "%ld (%08lx)\n", dwKeyLen, GetLastError()); result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 56 || broken(dwKeyLen == 40), "%d (%08x)\n", dwKeyLen, GetLastError()); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 56 || broken(dwKeyLen == 40), "%ld (%08lx)\n", dwKeyLen, GetLastError());
dwKeyLen = 128; SetLastError(0xdeadbeef); @@ -1558,55 +1558,55 @@ static void test_rc2(void) if (!BASE_PROV) { dwKeyLen = 12345; - ok(result, "expected success, got error 0x%08X\n", GetLastError()); + ok(result, "expected success, got error 0x%08lX\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 128, "Expected 128, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 128, "Expected 128, got %ld\n", dwKeyLen); } else { ok(!result, "expected error\n"); - ok(GetLastError() == NTE_BAD_DATA, "Expected 0x80009005, got 0x%08X\n", GetLastError()); + ok(GetLastError() == NTE_BAD_DATA, "Expected 0x80009005, got 0x%08lX\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 40, "Expected 40, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 40, "Expected 40, got %ld\n", dwKeyLen); }
dwLen = sizeof(dwKeyLen); result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError()); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 56, "%ld (%08lx)\n", dwKeyLen, GetLastError()); result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok((!BASE_PROV && dwKeyLen == 128) || (BASE_PROV && dwKeyLen == 40), - "%d (%08x)\n", dwKeyLen, GetLastError()); + "%ld (%08lx)\n", dwKeyLen, GetLastError());
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwDataLen = 13; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(!memcmp(pbData, !BASE_PROV ? rc2_128_encrypted : rc2_40def_encrypted, sizeof(rc2_128_encrypted)), "RC2 encryption failed!\n");
/* Oddly enough this succeeds, though it should have no effect */ dwKeyLen = 40; result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (LPBYTE)&dwKeyLen, 0); - ok(result, "%d\n", GetLastError()); + ok(result, "%ld\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Test a 40 bit key with salt */ result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDeriveKey(hProv, CALG_RC2, hHash, (40<<16)|CRYPT_CREATE_SALT, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwDataLen = 16; memset(pbData, 0xAF, dwDataLen); @@ -1623,28 +1623,28 @@ static void test_rc2(void) { error = GetLastError(); ok(error == NTE_BAD_DATA || broken(error == NTE_DOUBLE_ENCRYPT), - "Expected 0x80009005, got 0x%08X\n", error); + "Expected 0x80009005, got 0x%08lX\n", error); } dwLen = sizeof(DWORD); dwKeyLen = 12345; result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 40, "Expected 40, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 40, "Expected 40, got %ld\n", dwKeyLen);
dwLen = sizeof(pszBuffer); memset(pszBuffer, 0xAF, dwLen); result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!ENHANCED_PROV) - ok(dwLen == 11, "Expected 11, got %d\n", dwLen); + ok(dwLen == 11, "Expected 11, got %ld\n", dwLen); else - ok(dwLen == 0, "Expected 0, got %d\n", dwLen); + ok(dwLen == 0, "Expected 0, got %ld\n", dwLen);
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); } }
@@ -1673,108 +1673,108 @@ static void test_rc4(void) result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); + ok(GetLastError() == NTE_BAD_ALGID, "%08lx\n", GetLastError()); } else { CRYPT_INTEGER_BLOB salt;
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = 16; result = CryptGetHashParam(hHash, HP_HASHVAL, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDeriveKey(hProv, CALG_RC4, hHash, 56 << 16, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 56, "Expected 56, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 56, "Expected 56, got %ld\n", dwKeyLen);
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 0, "Expected 0, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 0, "Expected 0, got %ld\n", dwKeyLen);
dwLen = 0; result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0);
dwLen = 0; result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwMode == 0 || broken(dwMode == CRYPT_MODE_CBC) /* <= 2000 */, - "Expected 0, got %d\n", dwMode); + "Expected 0, got %ld\n", dwMode);
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwDataLen = 16; result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwDataLen, 24); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); dwDataLen = 16; result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(pbData, rc4, dwDataLen), "RC4 encryption failed!\n");
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Setting the salt value will not reset the salt length in base or strong providers */ result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0); - ok(result, "setting salt failed: %08x\n", GetLastError()); + ok(result, "setting salt failed: %08lx\n", GetLastError()); dwLen = 0; result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (BASE_PROV || STRONG_PROV) - ok(dwLen == 11, "expected salt length 11, got %d\n", dwLen); + ok(dwLen == 11, "expected salt length 11, got %ld\n", dwLen); else - ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %d\n", dwLen); + ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %ld\n", dwLen); /* What sizes salt can I set? */ salt.pbData = pbData; for (i=0; i<24; i++) { salt.cbData = i; result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0); - ok(result, "setting salt failed for size %d: %08x\n", i, GetLastError()); + ok(result, "setting salt failed for size %d: %08lx\n", i, GetLastError()); /* The returned salt length is the same as the set salt length */ result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == i, "size %d: unexpected salt length %d\n", i, dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == i, "size %d: unexpected salt length %ld\n", i, dwLen); } salt.cbData = 25; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0); ok(!result || broken(result), /* Win9x, WinMe, NT4, W2K */ - "%08x\n", GetLastError()); + "%08lx\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Test a 40 bit key with salt */ result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHash, pbData, sizeof(pbData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDeriveKey(hProv, CALG_RC4, hHash, (40<<16)|CRYPT_CREATE_SALT, &hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); dwDataLen = 16; memset(pbData, 0xAF, dwDataLen); SetLastError(0xdeadbeef); result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok((ENHANCED_PROV && !memcmp(pbData, rc4_40_salt, dwDataLen)) || (!ENHANCED_PROV && !memcmp(pbData, rc4_40_salt_base, dwDataLen)), "RC4 encryption failed!\n"); @@ -1782,23 +1782,23 @@ static void test_rc4(void) dwLen = sizeof(DWORD); dwKeyLen = 12345; result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); - ok(dwKeyLen == 40, "Expected 40, got %d\n", dwKeyLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwKeyLen == 40, "Expected 40, got %ld\n", dwKeyLen);
dwLen = sizeof(pszBuffer); memset(pszBuffer, 0xAF, dwLen); result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!ENHANCED_PROV) - ok(dwLen == 11, "Expected 11, got %d\n", dwLen); + ok(dwLen == 11, "Expected 11, got %ld\n", dwLen); else - ok(dwLen == 0, "Expected 0, got %d\n", dwLen); + ok(dwLen == 0, "Expected 0, got %ld\n", dwLen);
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); } }
@@ -1820,30 +1820,30 @@ static void test_hmac(void) { if (!derive_key(CALG_RC2, &hKey, 56)) return;
result = CryptCreateHash(hProv, CALG_HMAC, hKey, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptSetHashParam(hHash, HP_HMAC_INFO, (BYTE*)&hmacInfo, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptHashData(hHash, abData, sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = ARRAY_SIZE(abData); result = CryptGetHashParam(hHash, HP_HASHVAL, abData, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
ok(!memcmp(abData, hmac, sizeof(hmac)), "HMAC failed!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Provoke errors */ result = CryptCreateHash(hProv, CALG_HMAC, 0, 0, &hHash); - ok(!result && GetLastError() == NTE_BAD_KEY, "%08x\n", GetLastError()); + ok(!result && GetLastError() == NTE_BAD_KEY, "%08lx\n", GetLastError()); }
static void test_mac(void) { @@ -1862,26 +1862,26 @@ static void test_mac(void) {
dwLen = 256; result = CryptEncrypt(hKey, 0, TRUE, 0, abEnc, &dwLen, 264); - ok (result && dwLen == 264, "%08x, dwLen: %d\n", GetLastError(), dwLen); + ok (result && dwLen == 264, "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
result = CryptCreateHash(hProv, CALG_MAC, hKey, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHash, abData, sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
dwLen = ARRAY_SIZE(abData); result = CryptGetHashParam(hHash, HP_HASHVAL, abData, &dwLen, 0); - ok(result && dwLen == 8, "%08x, dwLen: %d\n", GetLastError(), dwLen); + ok(result && dwLen == 8, "%08lx, dwLen: %ld\n", GetLastError(), dwLen);
ok(!memcmp(abData, mac_40, sizeof(mac_40)), "MAC failed!\n");
result = CryptDestroyHash(hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
/* Provoke errors */ if (!derive_key(CALG_RC4, &hKey, 56)) return; @@ -1890,10 +1890,10 @@ static void test_mac(void) { result = CryptCreateHash(hProv, CALG_MAC, hKey, 0, &hHash); ok((!result && GetLastError() == NTE_BAD_KEY) || broken(result), /* Win9x, WinMe, NT4, W2K */ - "%08x\n", GetLastError()); + "%08lx\n", GetLastError());
result = CryptDestroyKey(hKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); }
static void test_import_private(void) @@ -1932,29 +1932,29 @@ static void test_import_private(void) result = CryptImportKey(hProv, abPlainPrivateKey, dwLen, 0, 0, &hKeyExchangeKey); if (!result) { /* rsaenh compiled without OpenSSL */ - ok(GetLastError() == NTE_FAIL, "%08x\n", GetLastError()); + ok(GetLastError() == NTE_FAIL, "%08lx\n", GetLastError()); return; }
dwLen = (DWORD)sizeof(abSessionKey); result = CryptImportKey(hProv, abSessionKey, dwLen, hKeyExchangeKey, 0, &hSessionKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hSessionKey, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal);
dwLen = (DWORD)sizeof(abEncryptedMessage); result = CryptDecrypt(hSessionKey, 0, TRUE, 0, abEncryptedMessage, &dwLen); - ok(result, "%08x\n", GetLastError()); - ok(dwLen == 12, "expected 12, got %d\n", dwLen); + ok(result, "%08lx\n", GetLastError()); + ok(dwLen == 12, "expected 12, got %ld\n", dwLen); ok(!memcmp(abEncryptedMessage, "Wine rocks!", 12), "decrypt failed\n"); CryptDestroyKey(hSessionKey);
@@ -1962,13 +1962,13 @@ static void test_import_private(void)
dwLen = (DWORD)sizeof(abSessionKey); result = CryptExportKey(hSessionKey, hKeyExchangeKey, SIMPLEBLOB, 0, abSessionKey, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); CryptDestroyKey(hSessionKey); if (!result) return;
dwLen = (DWORD)sizeof(abSessionKey); result = CryptImportKey(hProv, abSessionKey, dwLen, hKeyExchangeKey, 0, &hSessionKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
CryptDestroyKey(hSessionKey); @@ -1982,7 +1982,7 @@ static void test_import_private(void) for (; dwLen < sizeof(abPlainPrivateKey); dwLen++) { result = CryptImportKey(hProv, abPlainPrivateKey, dwLen, 0, 0, &hKeyExchangeKey); - ok(result, "CryptImportKey failed at size %d: %d (%08x)\n", dwLen, + ok(result, "CryptImportKey failed at size %ld: %ld (%08lx)\n", dwLen, GetLastError(), GetLastError()); if (result) CryptDestroyKey(hKeyExchangeKey); @@ -2169,21 +2169,21 @@ static void test_verify_signature(void) { };
result = CryptImportKey(hProv, abPubKey, 148, 0, 0, &hPubSignKey); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHash, abData, (DWORD)sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
/*check that a NULL pointer signature is correctly handled*/ result = CryptVerifySignatureA(hHash, NULL, 128, hPubSignKey, NULL, 0); ok(!result && ERROR_INVALID_PARAMETER == GetLastError(), - "Expected ERROR_INVALID_PARAMETER error, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER error, got %08lx\n", GetLastError()); if (result) return;
/* check that we get a bad signature error when the signature is too short*/ @@ -2191,85 +2191,85 @@ static void test_verify_signature(void) { result = CryptVerifySignatureA(hHash, abSignatureMD2, 64, hPubSignKey, NULL, 0); ok((!result && NTE_BAD_SIGNATURE == GetLastError()) || broken(result), /* Win9x, WinMe, NT4 */ - "Expected NTE_BAD_SIGNATURE, got %08x\n", GetLastError()); + "Expected NTE_BAD_SIGNATURE, got %08lx\n", GetLastError());
result = CryptVerifySignatureA(hHash, abSignatureMD2, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
/* It seems that CPVerifySignature doesn't care about the OID at all. */ result = CryptVerifySignatureA(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
CryptDestroyHash(hHash);
result = CryptCreateHash(hProv, CALG_MD4, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHash, abData, (DWORD)sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD4, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD4NoOID, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD4NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
CryptDestroyHash(hHash);
result = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHash, abData, (DWORD)sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD5, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD5NoOID, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureMD5NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
CryptDestroyHash(hHash);
result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHash, abData, (DWORD)sizeof(abData), 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureSHA, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureSHANoOID, 128, hPubSignKey, NULL, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptVerifySignatureA(hHash, abSignatureSHANoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); if (!result) return;
CryptDestroyHash(hHash); @@ -2286,7 +2286,7 @@ static void test_rsa_encrypt(void)
/* It is allowed to use the key exchange key for encryption/decryption */ result = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hRSAKey); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
dwLen = 12; @@ -2296,16 +2296,16 @@ static void test_rsa_encrypt(void) CryptDestroyKey(hRSAKey); return; } - ok(result, "CryptEncrypt failed: %08x\n", GetLastError()); - ok(dwLen == 128, "Unexpected length %d\n", dwLen); + ok(result, "CryptEncrypt failed: %08lx\n", GetLastError()); + ok(dwLen == 128, "Unexpected length %ld\n", dwLen); /* PKCS1 V1.5 */ dwLen = 12; result = CryptEncrypt(hRSAKey, 0, TRUE, 0, abData, &dwLen, (DWORD)sizeof(abData)); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptDecrypt(hRSAKey, 0, TRUE, 0, abData, &dwLen); - ok (result && dwLen == 12 && !memcmp(abData, "Wine rocks!", 12), "%08x\n", GetLastError()); + ok (result && dwLen == 12 && !memcmp(abData, "Wine rocks!", 12), "%08lx\n", GetLastError());
/* OAEP, RFC 8017 PKCS #1 V2.2 */ /* Test minimal buffer length requirement */ @@ -2313,13 +2313,13 @@ static void test_rsa_encrypt(void) SetLastError(0xdeadbeef); result = CryptEncrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen, 20 * 2 + 2); err = GetLastError(); - ok(!result && err == ERROR_MORE_DATA, "%08x\n", err); + ok(!result && err == ERROR_MORE_DATA, "%08lx\n", err);
/* Test data length limit */ dwLen = sizeof(abData) - (20 * 2 + 2) + 1; result = CryptEncrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen, (DWORD)sizeof(abData)); err = GetLastError(); - ok(!result && err == NTE_BAD_LEN, "%08x\n", err); + ok(!result && err == NTE_BAD_LEN, "%08lx\n", err);
/* Test malformed data */ dwLen = 12; @@ -2328,61 +2328,61 @@ static void test_rsa_encrypt(void) result = CryptDecrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen); err = GetLastError(); /* NTE_DOUBLE_ENCRYPT on xp or 2003 */ - ok(!result && (err == NTE_BAD_DATA || broken(err == NTE_DOUBLE_ENCRYPT)), "%08x\n", err); + ok(!result && (err == NTE_BAD_DATA || broken(err == NTE_DOUBLE_ENCRYPT)), "%08lx\n", err);
/* Test decrypt with insufficient buffer */ dwLen = 12; SetLastError(0xdeadbeef); memcpy(abData, "Wine rocks!", 12); result = CryptEncrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen, (DWORD)sizeof(abData)); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); dwLen = 11; SetLastError(0xdeadbeef); result = CryptDecrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen); err = GetLastError(); /* broken on xp or 2003 */ ok((!result && dwLen == 11 && err == NTE_BAD_DATA) || broken(result == TRUE && dwLen == 12 && err == ERROR_NO_TOKEN), - "%08x %d %08x\n", result, dwLen, err); + "%08x %ld %08lx\n", result, dwLen, err);
/* Test normal encryption and decryption */ dwLen = 12; memcpy(abData, "Wine rocks!", dwLen); result = CryptEncrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen, (DWORD)sizeof(abData)); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); result = CryptDecrypt(hRSAKey, 0, TRUE, CRYPT_OAEP, abData, &dwLen); - ok(result && dwLen == 12 && !memcmp(abData, "Wine rocks!", 12), "%08x\n", GetLastError()); + ok(result && dwLen == 12 && !memcmp(abData, "Wine rocks!", 12), "%08lx\n", GetLastError());
dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal);
/* An RSA key doesn't support salt */ result = CryptGetKeyParam(hRSAKey, KP_SALT, NULL, &dwLen, 0); ok(!result && (GetLastError() == NTE_BAD_KEY || GetLastError() == NTE_NOT_FOUND /* Win7 */), - "expected NTE_BAD_KEY or NTE_NOT_FOUND, got %08x\n", GetLastError()); + "expected NTE_BAD_KEY or NTE_NOT_FOUND, got %08lx\n", GetLastError());
/* The key exchange key's public key may be exported.. */ result = CryptExportKey(hRSAKey, 0, PUBLICKEYBLOB, 0, NULL, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); /* but its private key may not be. */ SetLastError(0xdeadbeef); result = CryptExportKey(hRSAKey, 0, PRIVATEKEYBLOB, 0, NULL, &dwLen); ok((!result && GetLastError() == NTE_BAD_KEY_STATE) || broken(result), /* Win9x/NT4 */ - "expected NTE_BAD_KEY_STATE, got %08x\n", GetLastError()); + "expected NTE_BAD_KEY_STATE, got %08lx\n", GetLastError()); /* Setting the permissions of the key exchange key isn't allowed, either. */ dwVal |= CRYPT_EXPORT; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE *)&dwVal, 0); ok(!result && (GetLastError() == NTE_BAD_DATA || GetLastError() == NTE_BAD_FLAGS), - "expected NTE_BAD_DATA or NTE_BAD_FLAGS, got %08x\n", GetLastError()); + "expected NTE_BAD_DATA or NTE_BAD_FLAGS, got %08lx\n", GetLastError());
CryptDestroyKey(hRSAKey);
@@ -2390,40 +2390,40 @@ static void test_rsa_encrypt(void) result = CryptGetUserKey(hProv, AT_SIGNATURE, &hRSAKey); if (!result) { - skip("No signature key in provider %s found, error %#x.\n", szProviders[iProv], GetLastError()); + skip("No signature key in provider %s found, error %#lx.\n", szProviders[iProv], GetLastError()); return; }
dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal);
/* The signature key's public key may also be exported.. */ result = CryptExportKey(hRSAKey, 0, PUBLICKEYBLOB, 0, NULL, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); /* but its private key may not be. */ SetLastError(0xdeadbeef); result = CryptExportKey(hRSAKey, 0, PRIVATEKEYBLOB, 0, NULL, &dwLen); ok((!result && GetLastError() == NTE_BAD_KEY_STATE) || broken(result), /* Win9x/NT4 */ - "expected NTE_BAD_KEY_STATE, got %08x\n", GetLastError()); + "expected NTE_BAD_KEY_STATE, got %08lx\n", GetLastError()); /* Setting the permissions of the signature key isn't allowed, either. */ dwVal |= CRYPT_EXPORT; SetLastError(0xdeadbeef); result = CryptSetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE *)&dwVal, 0); ok(!result && (GetLastError() == NTE_BAD_DATA || GetLastError() == NTE_BAD_FLAGS), - "expected NTE_BAD_DATA or NTE_BAD_FLAGS, got %08x\n", GetLastError()); + "expected NTE_BAD_DATA or NTE_BAD_FLAGS, got %08lx\n", GetLastError());
dwLen = 12; result = CryptEncrypt(hRSAKey, 0, TRUE, 0, abData, &dwLen, (DWORD)sizeof(abData)); - ok (!result && GetLastError() == NTE_BAD_KEY, "%08x\n", GetLastError()); + ok (!result && GetLastError() == NTE_BAD_KEY, "%08lx\n", GetLastError());
CryptDestroyKey(hRSAKey); } @@ -2615,15 +2615,15 @@ static void test_import_export(void) dwVal = 0xdeadbeef; dwDataLen = sizeof(DWORD); result = CryptGetKeyParam(hPublicKey, KP_PERMISSIONS, (BYTE*)&dwVal, &dwDataLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal); result = CryptExportKey(hPublicKey, 0, PUBLICKEYBLOB, 0, emptyKey, &dwLen); ok(result, "failed to export the fresh imported public key\n"); - ok(dwLen == 84, "Expected exported key to be 84 bytes long but got %d bytes.\n",dwLen); + ok(dwLen == 84, "Expected exported key to be 84 bytes long but got %ld bytes.\n",dwLen); ok(!memcmp(emptyKey, abPlainPublicKey, dwLen), "exported key is different from the imported key\n");
CryptDestroyKey(hPublicKey); @@ -2631,16 +2631,16 @@ static void test_import_export(void) /* imports into AT_SIGNATURE key container */ result = CryptImportKey(hProv, priv_key_with_high_bit, sizeof(priv_key_with_high_bit), 0, CRYPT_EXPORTABLE, &hPrivKey); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError());
result = CryptExportKey(hPrivKey, 0, PRIVATEKEYBLOB, 0, NULL, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); exported_key = HeapAlloc(GetProcessHeap(), 0, dwDataLen); result = CryptExportKey(hPrivKey, 0, PRIVATEKEYBLOB, 0, exported_key, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError());
- ok(dwDataLen == sizeof(expected_exported_priv_key), "unexpected size %d\n", + ok(dwDataLen == sizeof(expected_exported_priv_key), "unexpected size %ld\n", dwDataLen); ok(!memcmp(exported_key, expected_exported_priv_key, dwDataLen), "unexpected value\n"); @@ -2652,33 +2652,33 @@ static void test_import_export(void) /* imports into AT_KEYEXCHANGE key container */ result = CryptImportKey(hProv, abPlainPrivateKey, sizeof(abPlainPrivateKey), 0, 0, &hPrivKey); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError());
result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, NULL, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); exported_key = HeapAlloc(GetProcessHeap(), 0, dwDataLen); result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, exported_key, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); CryptDestroyKey(hPrivKey);
/* getting the public key from AT_KEYEXCHANGE, and compare it */ result = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hPrivKey); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, NULL, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); exported_key2 = HeapAlloc(GetProcessHeap(), 0, dwDataLen); result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, exported_key2, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); CryptDestroyKey(hPrivKey);
result = !memcmp(exported_key, exported_key2, dwDataLen); ok(result, "unexpected value\n"); if (!result && winetest_debug > 1) { - trace("Expected public key (%u):\n", dwDataLen); + trace("Expected public key (%lu):\n", dwDataLen); trace_hex(exported_key, dwDataLen); - trace("AT_KEYEXCHANGE public key (%u):\n", dwDataLen); + trace("AT_KEYEXCHANGE public key (%lu):\n", dwDataLen); trace_hex(exported_key2, dwDataLen); } HeapFree(GetProcessHeap(), 0, exported_key2); @@ -2691,21 +2691,21 @@ static void test_import_export(void)
/* getting the public key again, and compare it */ result = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hPrivKey); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, NULL, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); exported_key2 = HeapAlloc(GetProcessHeap(), 0, dwDataLen); result = CryptExportKey(hPrivKey, 0, PUBLICKEYBLOB, 0, exported_key2, &dwDataLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); CryptDestroyKey(hPrivKey);
result = !memcmp(exported_key, exported_key2, dwDataLen); ok(result, "unexpected value\n"); if (!result && winetest_debug > 1) { - trace("Expected public key (%u):\n", dwDataLen); + trace("Expected public key (%lu):\n", dwDataLen); trace_hex(exported_key, dwDataLen); - trace("AT_KEYEXCHANGE public key (%u):\n", dwDataLen); + trace("AT_KEYEXCHANGE public key (%lu):\n", dwDataLen); trace_hex(exported_key2, dwDataLen); }
@@ -2796,7 +2796,7 @@ static void test_import_hmac(void) *key_len = test_case->key_len; memcpy(key_bytes, test_case->key, *key_len); result = CryptImportKey(hProv, blob, size, 0, CRYPT_IPSEC_HMAC_KEY, &key); - ok(result || broken(GetLastError() == NTE_BAD_FLAGS /* Win2k */), "CryptImportKey failed on test case %d: %08x\n", i, GetLastError()); + ok(result || broken(GetLastError() == NTE_BAD_FLAGS /* Win2k */), "CryptImportKey failed on test case %ld: %08lx\n", i, GetLastError()); if (result) { HCRYPTHASH hash; @@ -2805,15 +2805,15 @@ static void test_import_hmac(void) DWORD digest_size;
result = CryptCreateHash(hProv, CALG_HMAC, key, 0, &hash); - ok(result, "CryptCreateHash failed on test case %d: %08x\n", i, GetLastError()); + ok(result, "CryptCreateHash failed on test case %ld: %08lx\n", i, GetLastError()); result = CryptSetHashParam(hash, HP_HMAC_INFO, (BYTE *)&hmac_info, 0); - ok(result, "CryptSetHashParam failed on test case %d: %08x\n", i, GetLastError()); + ok(result, "CryptSetHashParam failed on test case %ld: %08lx\n", i, GetLastError()); result = CryptHashData(hash, (const BYTE *)test_case->data, test_case->data_len, 0); - ok(result, "CryptHashData failed on test case %d: %08x\n", i, GetLastError()); + ok(result, "CryptHashData failed on test case %ld: %08lx\n", i, GetLastError()); digest_size = sizeof(digest); result = CryptGetHashParam(hash, HP_HASHVAL, digest, &digest_size, 0); - ok(result, "CryptGetHashParam failed on test case %d: %08x\n", i, GetLastError()); - ok(!memcmp(digest, test_case->digest, sizeof(digest)), "Unexpected value on test case %d\n", i); + ok(result, "CryptGetHashParam failed on test case %ld: %08lx\n", i, GetLastError()); + ok(!memcmp(digest, test_case->digest, sizeof(digest)), "Unexpected value on test case %ld\n", i); CryptDestroyHash(hash); CryptDestroyKey(key); } @@ -2877,12 +2877,12 @@ static void test_schannel_provider(void) win_skip("no PROV_RSA_SCHANNEL support\n"); return; } - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (result) CryptReleaseContext(hProv, 0);
result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_RSA_SCHANNEL, CRYPT_VERIFYCONTEXT); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* To get deterministic results, we import the TLS1 master secret (which @@ -2890,12 +2890,12 @@ static void test_schannel_provider(void) * an RSA key. */ dwLen = (DWORD)sizeof(abPlainPrivateKey); result = CryptImportKey(hProv, abPlainPrivateKey, dwLen, 0, 0, &hRSAKey); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
dwLen = (DWORD)sizeof(abTLS1Master); result = CryptImportKey(hProv, abTLS1Master, dwLen, hRSAKey, 0, &hMasterSecret); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* Deriving a hash from the master secret. This is due to the CryptoAPI architecture. @@ -2905,26 +2905,26 @@ static void test_schannel_provider(void) */ result = CryptCreateHash(hProv, CALG_SCHANNEL_MASTER_HASH, hMasterSecret, 0, &hMasterHash); ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, - "expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + "expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
/* Setting the TLS1 client and server random parameters, as well as the * MAC and encryption algorithm parameters. */ data_blob.cbData = 33; data_blob.pbData = abClientSecret; result = CryptSetKeyParam(hMasterSecret, KP_CLIENT_RANDOM, (BYTE*)&data_blob, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
data_blob.cbData = 33; data_blob.pbData = abServerSecret; result = CryptSetKeyParam(hMasterSecret, KP_SERVER_RANDOM, (BYTE*)&data_blob, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptCreateHash(hProv, CALG_SCHANNEL_MASTER_HASH, hMasterSecret, 0, &hMasterHash); ok (result || broken(!result), /* Windows 8 and greater */ - "%08x\n", GetLastError()); + "%08lx\n", GetLastError()); if (!result) { win_skip("Broken TLS1 hash creation\n"); @@ -2940,7 +2940,7 @@ static void test_schannel_provider(void) */ result = CryptDeriveKey(hProv, CALG_SCHANNEL_ENC_KEY, hMasterHash, CRYPT_SERVER, &hServerWriteKey); ok (!result && GetLastError() == NTE_BAD_FLAGS, - "expected NTE_BAD_FLAGS, got %08x\n", GetLastError()); + "expected NTE_BAD_FLAGS, got %08lx\n", GetLastError());
CryptDestroyHash(hMasterHash);
@@ -2950,7 +2950,7 @@ static void test_schannel_provider(void) saSChannelAlg.dwFlags = 0; saSChannelAlg.dwReserved = 0; result = CryptSetKeyParam(hMasterSecret, KP_SCHANNEL_ALG, (PBYTE)&saSChannelAlg, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
saSChannelAlg.dwUse = SCHANNEL_MAC_KEY; @@ -2959,68 +2959,68 @@ static void test_schannel_provider(void) saSChannelAlg.dwFlags = 0; saSChannelAlg.dwReserved = 0; result = CryptSetKeyParam(hMasterSecret, KP_SCHANNEL_ALG, (PBYTE)&saSChannelAlg, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptCreateHash(hProv, CALG_SCHANNEL_MASTER_HASH, hMasterSecret, 0, &hMasterHash); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* Deriving the server write encryption key from the master hash */ result = CryptDeriveKey(hProv, CALG_SCHANNEL_ENC_KEY, hMasterHash, CRYPT_SERVER, &hServerWriteKey); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* Encrypting some data with the server write encryption key and checking the result. */ dwLen = 12; result = CryptEncrypt(hServerWriteKey, 0, TRUE, 0, abData, &dwLen, 16); - ok (result && (dwLen == 16) && !memcmp(abData, abEncryptedData, 16), "%08x\n", GetLastError()); + ok (result && (dwLen == 16) && !memcmp(abData, abEncryptedData, 16), "%08lx\n", GetLastError());
/* Second test case: Test the TLS1 pseudo random number function. */ result = CryptCreateHash(hProv, CALG_TLS1PRF, hMasterSecret, 0, &hTLS1PRF); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* Set the label and seed parameters for the random number function */ data_blob.cbData = 36; data_blob.pbData = abHashedHandshakes; result = CryptSetHashParam(hTLS1PRF, HP_TLS1PRF_SEED, (BYTE*)&data_blob, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
data_blob.cbData = 15; data_blob.pbData = abClientFinished; result = CryptSetHashParam(hTLS1PRF, HP_TLS1PRF_LABEL, (BYTE*)&data_blob, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
/* Generate some pseudo random bytes and check if they are correct. */ dwLen = (DWORD)sizeof(abData); result = CryptGetHashParam(hTLS1PRF, HP_HASHVAL, abData, &dwLen, 0); ok (result && (dwLen==(DWORD)sizeof(abData)) && !memcmp(abData, abPRF, sizeof(abData)), - "%08x\n", GetLastError()); + "%08lx\n", GetLastError());
/* Third test case. Derive the server write mac key. Derive an HMAC object from this one. * Hash some data with the HMAC. Compare results. */ result = CryptDeriveKey(hProv, CALG_SCHANNEL_MAC_KEY, hMasterHash, CRYPT_SERVER, &hServerWriteMACKey); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptCreateHash(hProv, CALG_HMAC, hServerWriteMACKey, 0, &hHMAC); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptSetHashParam(hHMAC, HP_HMAC_INFO, (PBYTE)&hmacInfo, 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
result = CryptHashData(hHMAC, abData, (DWORD)sizeof(abData), 0); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
dwLen = (DWORD)sizeof(abMD5Hash); result = CryptGetHashParam(hHMAC, HP_HASHVAL, abMD5Hash, &dwLen, 0); - ok (result && (dwLen == 16) && !memcmp(abMD5Hash, abMD5, 16), "%08x\n", GetLastError()); + ok (result && (dwLen == 16) && !memcmp(abMD5Hash, abMD5, 16), "%08lx\n", GetLastError());
CryptDestroyHash(hHMAC); CryptDestroyHash(hTLS1PRF); @@ -3052,11 +3052,11 @@ static void test_rsa_round_trip(void) /* Generate a new key... */ result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); result = CryptGenKey(prov, CALG_RSA_KEYX, CRYPT_EXPORTABLE, &signKey); - ok(result, "CryptGenKey with CALG_RSA_KEYX failed with error %08x\n", GetLastError()); + ok(result, "CryptGenKey with CALG_RSA_KEYX failed with error %08lx\n", GetLastError()); result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &keyExchangeKey); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); /* encrypt some data with it... */ memcpy(data, test_string, strlen(test_string) + 1); dataLen = strlen(test_string) + 1; @@ -3064,21 +3064,21 @@ static void test_rsa_round_trip(void) sizeof(data)); ok(result || broken(GetLastError() == NTE_BAD_KEY /* Win9x/2000 */) || broken(GetLastError() == NTE_PERM /* NT4 */), - "CryptEncrypt failed: %08x\n", GetLastError()); + "CryptEncrypt failed: %08lx\n", GetLastError()); /* export the key... */ result = CryptExportKey(keyExchangeKey, 0, PRIVATEKEYBLOB, 0, NULL, &keyLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); exportedKey = HeapAlloc(GetProcessHeap(), 0, keyLen); result = CryptExportKey(keyExchangeKey, 0, PRIVATEKEYBLOB, 0, exportedKey, &keyLen); - ok(result, "CryptExportKey failed: %08x\n", GetLastError()); + ok(result, "CryptExportKey failed: %08lx\n", GetLastError()); /* destroy the key... */ CryptDestroyKey(keyExchangeKey); CryptDestroyKey(signKey); /* import the key again... */ result = CryptImportKey(prov, exportedKey, keyLen, 0, 0, &keyExchangeKey); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError()); HeapFree(GetProcessHeap(), 0, exportedKey); /* and decrypt the data encrypted with the original key with the imported * key. @@ -3086,10 +3086,10 @@ static void test_rsa_round_trip(void) result = CryptDecrypt(keyExchangeKey, 0, TRUE, 0, data, &dataLen); ok(result || broken(GetLastError() == NTE_BAD_KEY /* Win9x/2000 */) || broken(GetLastError() == NTE_PERM /* NT4 */), - "CryptDecrypt failed: %08x\n", GetLastError()); + "CryptDecrypt failed: %08lx\n", GetLastError()); if (result) { - ok(dataLen == sizeof(test_string), "unexpected size %d\n", dataLen); + ok(dataLen == sizeof(test_string), "unexpected size %ld\n", dataLen); ok(!memcmp(data, test_string, sizeof(test_string)), "unexpected value\n"); } CryptDestroyKey(keyExchangeKey); @@ -3109,15 +3109,15 @@ static void test_enum_container(void) * the maximum legal length of container names (which is MAX_PATH + 1 == 261) */ SetLastError(0xdeadbeef); result = CryptGetProvParam(hProv, PP_ENUMCONTAINERS, NULL, &dwBufferLen, CRYPT_FIRST); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); ok (dwBufferLen == MAX_PATH + 1 || broken(dwBufferLen != MAX_PATH + 1), /* Win9x, WinMe, NT4 */ - "Expected dwBufferLen to be (MAX_PATH + 1), it was : %d\n", dwBufferLen); + "Expected dwBufferLen to be (MAX_PATH + 1), it was : %ld\n", dwBufferLen);
/* If the result fits into abContainerName dwBufferLen is left untouched */ dwBufferLen = (DWORD)sizeof(abContainerName); result = CryptGetProvParam(hProv, PP_ENUMCONTAINERS, abContainerName, &dwBufferLen, CRYPT_FIRST); - ok (result && dwBufferLen == (DWORD)sizeof(abContainerName), "%08x\n", GetLastError()); + ok (result && dwBufferLen == (DWORD)sizeof(abContainerName), "%08lx\n", GetLastError());
/* We only check, if the currently open 'winetest' container is among the enumerated. */ do { @@ -3125,7 +3125,7 @@ static void test_enum_container(void) dwBufferLen = (DWORD)sizeof(abContainerName); } while (CryptGetProvParam(hProv, PP_ENUMCONTAINERS, abContainerName, &dwBufferLen, 0));
- ok (fFound && GetLastError() == ERROR_NO_MORE_ITEMS, "%d, %08x\n", fFound, GetLastError()); + ok (fFound && GetLastError() == ERROR_NO_MORE_ITEMS, "%d, %08lx\n", fFound, GetLastError()); }
static BYTE signBlob[] = { @@ -3160,21 +3160,21 @@ static void test_null_provider(void)
result = CryptAcquireContextA(NULL, szContainer, NULL, 0, 0); ok(!result && GetLastError() == NTE_BAD_PROV_TYPE, - "Expected NTE_BAD_PROV_TYPE, got %08x\n", GetLastError()); + "Expected NTE_BAD_PROV_TYPE, got %08lx\n", GetLastError()); result = CryptAcquireContextA(NULL, szContainer, NULL, PROV_RSA_FULL, 0); ok(!result && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_KEYSET), - "Expected ERROR_INVALID_PARAMETER or NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER or NTE_BAD_KEYSET, got %08lx\n", GetLastError()); result = CryptAcquireContextA(NULL, szContainer, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(!result && ( GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_KEYSET), - "Expected ERROR_INVALID_PARAMETER or NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected ERROR_INVALID_PARAMETER or NTE_BAD_KEYSET, got %08lx\n", GetLastError()); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(!result && GetLastError() == NTE_BAD_KEYSET, - "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected NTE_BAD_KEYSET, got %08lx\n", GetLastError()); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, 0); ok(!result && GetLastError() == NTE_BAD_KEYSET, - "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected NTE_BAD_KEYSET, got %08lx\n", GetLastError());
/* Delete the default container. */ CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); @@ -3183,39 +3183,39 @@ static void test_null_provider(void) */ result = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, 0); ok(!result && GetLastError() == NTE_BAD_KEYSET, - "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected NTE_BAD_KEYSET, got %08lx\n", GetLastError()); /* But you can always open the default container for CRYPT_VERIFYCONTEXT. */ result = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); if (!result) return; dataLen = sizeof(keySpec); result = CryptGetProvParam(prov, PP_KEYSPEC, (LPBYTE)&keySpec, &dataLen, 0); if (result) ok(keySpec == (AT_KEYEXCHANGE | AT_SIGNATURE), - "Expected AT_KEYEXCHANGE | AT_SIGNATURE, got %08x\n", keySpec); + "Expected AT_KEYEXCHANGE | AT_SIGNATURE, got %08lx\n", keySpec); /* Even though PP_KEYSPEC says both AT_KEYEXCHANGE and AT_SIGNATURE are * supported, you can't get the keys from this container. */ result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); result = CryptGetUserKey(prov, AT_SIGNATURE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); result = CryptReleaseContext(prov, 0); - ok(result, "CryptReleaseContext failed: %08x\n", GetLastError()); + ok(result, "CryptReleaseContext failed: %08lx\n", GetLastError()); /* You can create a new default container. */ result = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); /* But you still can't get the keys (until one's been generated.) */ result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); result = CryptGetUserKey(prov, AT_SIGNATURE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); CryptReleaseContext(prov, 0); CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
@@ -3223,28 +3223,28 @@ static void test_null_provider(void) CRYPT_DELETEKEYSET); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, 0); ok(!result && GetLastError() == NTE_BAD_KEYSET, - "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected NTE_BAD_KEYSET, got %08lx\n", GetLastError()); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ok(!result && GetLastError() == NTE_BAD_FLAGS, - "Expected NTE_BAD_FLAGS, got %08x\n", GetLastError()); + "Expected NTE_BAD_FLAGS, got %08lx\n", GetLastError()); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); if (!result) return; /* Test provider parameters getter */ dataLen = sizeof(dwParam); result = CryptGetProvParam(prov, PP_PROVTYPE, (LPBYTE)&dwParam, &dataLen, 0); ok(result && dataLen == sizeof(dwParam) && dwParam == PROV_RSA_FULL, - "Expected PROV_RSA_FULL, got 0x%08X\n",dwParam); + "Expected PROV_RSA_FULL, got 0x%08lX\n",dwParam); dataLen = sizeof(dwParam); result = CryptGetProvParam(prov, PP_KEYSET_TYPE, (LPBYTE)&dwParam, &dataLen, 0); ok(result && dataLen == sizeof(dwParam) && dwParam == 0, - "Expected 0, got 0x%08X\n",dwParam); + "Expected 0, got 0x%08lX\n",dwParam); dataLen = sizeof(dwParam); result = CryptGetProvParam(prov, PP_KEYSTORAGE, (LPBYTE)&dwParam, &dataLen, 0); ok(result && dataLen == sizeof(dwParam) && (dwParam & CRYPT_SEC_DESCR), - "Expected CRYPT_SEC_DESCR to be set, got 0x%08X\n",dwParam); + "Expected CRYPT_SEC_DESCR to be set, got 0x%08lX\n",dwParam); dataLen = sizeof(keySpec); SetLastError(0xdeadbeef); result = CryptGetProvParam(prov, PP_KEYSPEC, (LPBYTE)&keySpec, &dataLen, 0); @@ -3252,12 +3252,12 @@ static void test_null_provider(void) skip("PP_KEYSPEC is not supported (win9x or NT)\n"); else ok(result && keySpec == (AT_KEYEXCHANGE | AT_SIGNATURE), - "Expected AT_KEYEXCHANGE | AT_SIGNATURE, got %08x\n", keySpec); + "Expected AT_KEYEXCHANGE | AT_SIGNATURE, got %08lx\n", keySpec); /* PP_CONTAINER parameter */ dataLen = sizeof(szName); result = CryptGetProvParam(prov, PP_CONTAINER, (LPBYTE)szName, &dataLen, 0); ok(result && dataLen == strlen(szContainer)+1 && strcmp(szContainer,szName) == 0, - "failed getting PP_CONTAINER. result = %s. Error 0x%08X. returned length = %d\n", + "failed getting PP_CONTAINER. result = %s. Error 0x%08lX. returned length = %ld\n", (result)? "TRUE":"FALSE",GetLastError(),dataLen); /* PP_UNIQUE_CONTAINER parameter */ dataLen = sizeof(szName); @@ -3271,13 +3271,13 @@ static void test_null_provider(void) { char container[MAX_PATH];
- ok(result, "failed getting PP_UNIQUE_CONTAINER : 0x%08X\n", GetLastError()); + ok(result, "failed getting PP_UNIQUE_CONTAINER : 0x%08lX\n", GetLastError()); uniquecontainer(container); todo_wine { ok(dataLen == strlen(container)+1 || broken(dataLen == strlen(szContainer)+1) /* WinME */, - "Expected a param length of 70, got %d\n", dataLen); + "Expected a param length of 70, got %ld\n", dataLen); ok(!strcmp(container, szName) || broken(!strcmp(szName, szContainer)) /* WinME */, "Wrong container name : %s\n", szName); @@ -3285,24 +3285,24 @@ static void test_null_provider(void) } result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); result = CryptGetUserKey(prov, AT_SIGNATURE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError());
/* Importing a key exchange blob.. */ result = CryptImportKey(prov, abPlainPrivateKey, sizeof(abPlainPrivateKey), 0, 0, &key); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError()); CryptDestroyKey(key); /* allows access to the key exchange key.. */ result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); CryptDestroyKey(key); /* but not to the private key. */ result = CryptGetUserKey(prov, AT_SIGNATURE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); CryptReleaseContext(prov, 0); CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); @@ -3310,18 +3310,18 @@ static void test_null_provider(void) /* Whereas importing a sign blob.. */ result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); if (!result) return; result = CryptImportKey(prov, signBlob, sizeof(signBlob), 0, 0, &key); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError()); CryptDestroyKey(key); /* doesn't allow access to the key exchange key.. */ result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); ok(!result && GetLastError() == NTE_NO_KEY, - "Expected NTE_NO_KEY, got %08x\n", GetLastError()); + "Expected NTE_NO_KEY, got %08lx\n", GetLastError()); /* but does to the private key. */ result = CryptGetUserKey(prov, AT_SIGNATURE, &key); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); CryptDestroyKey(key); CryptReleaseContext(prov, 0);
@@ -3331,14 +3331,14 @@ static void test_null_provider(void) /* Test for being able to get a key generated with CALG_RSA_SIGN. */ result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); result = CryptGenKey(prov, CALG_RSA_SIGN, 0, &key); - ok(result, "CryptGenKey with CALG_RSA_SIGN failed with error %08x\n", GetLastError()); + ok(result, "CryptGenKey with CALG_RSA_SIGN failed with error %08lx\n", GetLastError()); CryptDestroyKey(key); result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); ok(!result, "expected CryptGetUserKey to fail\n"); result = CryptGetUserKey(prov, AT_SIGNATURE, &key); - ok(result, "CryptGetUserKey with AT_SIGNATURE failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey with AT_SIGNATURE failed: %08lx\n", GetLastError()); CryptDestroyKey(key); CryptReleaseContext(prov, 0);
@@ -3348,12 +3348,12 @@ static void test_null_provider(void) /* Test for being able to get a key generated with CALG_RSA_KEYX. */ result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); result = CryptGenKey(prov, CALG_RSA_KEYX, 0, &key); - ok(result, "CryptGenKey with CALG_RSA_KEYX failed with error %08x\n", GetLastError()); + ok(result, "CryptGenKey with CALG_RSA_KEYX failed with error %08lx\n", GetLastError()); CryptDestroyKey(key); result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); - ok(result, "CryptGetUserKey with AT_KEYEXCHANGE failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey with AT_KEYEXCHANGE failed: %08lx\n", GetLastError()); CryptDestroyKey(key); result = CryptGetUserKey(prov, AT_SIGNATURE, &key); ok(!result, "expected CryptGetUserKey to fail\n"); @@ -3366,15 +3366,15 @@ static void test_null_provider(void) */ result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); result = CryptGenKey(prov, AT_KEYEXCHANGE, 0, &key); - ok(result, "CryptGenKey with AT_KEYEXCHANGE failed with error %08x\n", GetLastError()); + ok(result, "CryptGenKey with AT_KEYEXCHANGE failed with error %08lx\n", GetLastError()); CryptDestroyKey(key); CryptReleaseContext(prov,0); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL,0); - ok(result, "CryptAcquireContextA failed: 0x%08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: 0x%08lx\n", GetLastError()); result = CryptGetUserKey(prov, AT_KEYEXCHANGE, &key); - ok (result, "CryptGetUserKey failed with error %08x\n", GetLastError()); + ok (result, "CryptGetUserKey failed with error %08lx\n", GetLastError()); CryptDestroyKey(key); CryptReleaseContext(prov, 0);
@@ -3386,20 +3386,20 @@ static void test_null_provider(void) CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET); - ok(result, "CryptAcquireContextA with CRYPT_MACHINE_KEYSET failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA with CRYPT_MACHINE_KEYSET failed: %08lx\n", GetLastError()); CryptReleaseContext(prov, 0); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET); - ok(result, "CryptAcquireContextA with CRYPT_MACHINE_KEYSET failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA with CRYPT_MACHINE_KEYSET failed: %08lx\n", GetLastError()); CryptReleaseContext(prov,0); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET); - ok(result, "CryptAcquireContextA with CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET failed: %08x\n", + ok(result, "CryptAcquireContextA with CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET failed: %08lx\n", GetLastError()); result = CryptAcquireContextA(&prov, szContainer, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET); ok(!result && GetLastError() == NTE_BAD_KEYSET , - "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + "Expected NTE_BAD_KEYSET, got %08lx\n", GetLastError());
}
@@ -3414,50 +3414,50 @@ static void test_key_permissions(void) return;
result = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hKey1); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError()); if (!result) return;
dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey1, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal);
/* The key exchange key's public key may be exported.. */ result = CryptExportKey(hKey1, 0, PUBLICKEYBLOB, 0, NULL, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); /* and its private key may be too. */ result = CryptExportKey(hKey1, 0, PRIVATEKEYBLOB, 0, NULL, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); /* Turning off the key's export permissions is "allowed".. */ dwVal &= ~CRYPT_EXPORT; result = CryptSetKeyParam(hKey1, KP_PERMISSIONS, (BYTE *)&dwVal, 0); ok(result || broken(!result && GetLastError() == NTE_BAD_DATA) || /* W2K */ broken(!result && GetLastError() == NTE_BAD_FLAGS), /* Win9x/WinME/NT4 */ - "%08x\n", GetLastError()); + "%08lx\n", GetLastError()); /* but it has no effect. */ dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey1, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal); /* Thus, changing the export flag of the key doesn't affect whether the key * may be exported. */ result = CryptExportKey(hKey1, 0, PRIVATEKEYBLOB, 0, NULL, &dwLen); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError());
result = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hKey2); - ok (result, "%08x\n", GetLastError()); + ok (result, "%08lx\n", GetLastError());
/* A subsequent get of the same key, into a different handle, also doesn't * show that the permissions have been changed. @@ -3465,12 +3465,12 @@ static void test_key_permissions(void) dwVal = 0xdeadbeef; dwLen = sizeof(DWORD); result = CryptGetKeyParam(hKey2, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0); - ok(result, "%08x\n", GetLastError()); + ok(result, "%08lx\n", GetLastError()); ok(dwVal == (CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT) || broken(dwVal == 0xffffffff), /* Win9x/NT4 */ "expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT," - " got %08x\n", dwVal); + " got %08lx\n", dwVal);
CryptDestroyKey(hKey2); CryptDestroyKey(hKey1); @@ -3512,23 +3512,23 @@ static void test_key_initialization(void) { result = CryptAcquireContextA(&prov1, szContainer, szProvider, PROV_RSA_FULL, CRYPT_NEWKEYSET); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); } dwLen = (DWORD)sizeof(abPlainPrivateKey); result = CryptImportKey(prov1, abPlainPrivateKey, dwLen, 0, 0, &hKeyExchangeKey); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError());
dwLen = (DWORD)sizeof(abSessionKey); result = CryptImportKey(prov1, abSessionKey, dwLen, hKeyExchangeKey, 0, &hSessionKey); - ok(result, "CryptImportKey failed: %08x\n", GetLastError()); + ok(result, "CryptImportKey failed: %08lx\n", GetLastError());
/* Once the key has been imported, subsequently acquiring a context with * the same name will allow retrieving the key. */ result = CryptAcquireContextA(&prov2, szContainer, szProvider, PROV_RSA_FULL, 0); - ok(result, "CryptAcquireContextA failed: %08x\n", GetLastError()); + ok(result, "CryptAcquireContextA failed: %08lx\n", GetLastError()); result = CryptGetUserKey(prov2, AT_KEYEXCHANGE, &hKey); - ok(result, "CryptGetUserKey failed: %08x\n", GetLastError()); + ok(result, "CryptGetUserKey failed: %08lx\n", GetLastError()); if (result) CryptDestroyKey(hKey); CryptReleaseContext(prov2, 0);
@@ -3888,21 +3888,21 @@ static void test_key_derivation(const char *prov) if (!result) { /* rsaenh compiled without OpenSSL or not supported by provider */ - ok(GetLastError() == NTE_BAD_ALGID, "Test [%s %d]: Expected NTE_BAD_ALGID, got 0x%08x\n", + ok(GetLastError() == NTE_BAD_ALGID, "Test [%s %ld]: Expected NTE_BAD_ALGID, got 0x%08lx\n", prov, i, GetLastError()); continue; } - ok(result, "Test [%s %d]: CryptCreateHash failed with error 0x%08x\n", prov, i, GetLastError()); + ok(result, "Test [%s %ld]: CryptCreateHash failed with error 0x%08lx\n", prov, i, GetLastError()); result = CryptHashData(hHash, dvData, sizeof(dvData), 0); - ok(result, "Test [%s %d]: CryptHashData failed with error 0x%08x\n", prov, i, GetLastError()); + ok(result, "Test [%s %ld]: CryptHashData failed with error 0x%08lx\n", prov, i, GetLastError());
len = sizeof(pbData); result = CryptGetHashParam(hHash, HP_HASHVAL, pbData, &len, 0); - ok(result, "Test [%s %d]: CryptGetHashParam failed with error 0x%08x\n", prov, i, GetLastError()); - ok(len == tests[i].hashlen, "Test [%s %d]: Expected hash len %d, got %d\n", + ok(result, "Test [%s %ld]: CryptGetHashParam failed with error 0x%08lx\n", prov, i, GetLastError()); + ok(len == tests[i].hashlen, "Test [%s %ld]: Expected hash len %d, got %ld\n", prov, i, tests[i].hashlen, len); ok(!tests[i].hashlen || !memcmp(pbData, tests[i].expected_hash, tests[i].hashlen), - "Test [%s %d]: Hash comparison failed\n", prov, i); + "Test [%s %ld]: Hash comparison failed\n", prov, i);
SetLastError(0xdeadbeef); result = CryptDeriveKey(hProv, tests[i].crypt_algo, hHash, 0, &hKey); @@ -3910,23 +3910,23 @@ static void test_key_derivation(const char *prov) if(!result && (GetLastError() == tests[i].errorkey || GetLastError() == ERROR_INVALID_PARAMETER /* <= NT4*/)) goto err; - ok(result, "Test [%s %d]: CryptDeriveKey failed with error 0x%08x\n", prov, i, GetLastError()); + ok(result, "Test [%s %ld]: CryptDeriveKey failed with error 0x%08lx\n", prov, i, GetLastError());
len = sizeof(mode); mode = 0xdeadbeef; result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&mode, &len, 0); - ok(result, "Test [%s %d]: CryptGetKeyParam failed with error %08x\n", prov, i, GetLastError()); - ok(mode == tests[i].chain_mode, "Test [%s %d]: Expected chaining mode %d, got %d\n", + ok(result, "Test [%s %ld]: CryptGetKeyParam failed with error %08lx\n", prov, i, GetLastError()); + ok(mode == tests[i].chain_mode, "Test [%s %ld]: Expected chaining mode %d, got %ld\n", prov, i, tests[i].chain_mode, mode);
SetLastError(0xdeadbeef); len = 4; result = CryptEncrypt(hKey, 0, TRUE, 0, dvData, &len, sizeof(dvData)); - ok(result, "Test [%s %d]: CryptEncrypt failed with error 0x%08x\n", prov, i, GetLastError()); - ok(len == tests[i].blocklen, "Test [%s %d]: Expected block len %d, got %d\n", + ok(result, "Test [%s %ld]: CryptEncrypt failed with error 0x%08lx\n", prov, i, GetLastError()); + ok(len == tests[i].blocklen, "Test [%s %ld]: Expected block len %d, got %ld\n", prov, i, tests[i].blocklen, len); ok(!memcmp(dvData, tests[i].expected_enc, tests[i].blocklen), - "Test [%s %d]: Encrypted data comparison failed\n", prov, i); + "Test [%s %ld]: Encrypted data comparison failed\n", prov, i);
CryptDestroyKey(hKey); err: