From 9c245e9ec1d74c7bcda380c48df579ccb8a4ca27 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 17 Jan 2009 20:25:16 +0000 Subject: [PATCH] sync rsaenh_winetest with wine 1.1.13 svn path=/trunk/; revision=38848 --- rostests/winetests/rsaenh/rsaenh.c | 190 +++++++++++++++++++---------- 1 file changed, 126 insertions(+), 64 deletions(-) diff --git a/rostests/winetests/rsaenh/rsaenh.c b/rostests/winetests/rsaenh/rsaenh.c index 479b4286d46..60e8789475e 100644 --- a/rostests/winetests/rsaenh/rsaenh.c +++ b/rostests/winetests/rsaenh/rsaenh.c @@ -146,9 +146,16 @@ static void clean_up_base_environment(void) { BOOL result; + SetLastError(0xdeadbeef); result = CryptReleaseContext(hProv, 1); - ok(!result && GetLastError()==NTE_BAD_FLAGS, "%08x\n", GetLastError()); + ok(!result || broken(result) /* Win98 */, "Expected failure\n"); + ok(GetLastError()==NTE_BAD_FLAGS, "Expected NTE_BAD_FLAGS, got %08x\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()); + CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } @@ -167,6 +174,11 @@ static int init_aes_environment(void) * This provider is available on Windows XP, Windows 2003 and Vista. */ result = CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT); + if (!result && GetLastError() == NTE_PROV_TYPE_NOT_DEF) + { + win_skip("RSA_ASE provider not supported\n"); + return 0; + } ok(!result && GetLastError()==NTE_BAD_FLAGS, "%d, %08x\n", result, GetLastError()); if (!CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, 0)) @@ -248,7 +260,7 @@ static BOOL derive_key(ALG_ID aiAlgid, HCRYPTKEY *phKey, DWORD len) unsigned char pbData[2000]; int i; - *phKey = (HCRYPTKEY)NULL; + *phKey = 0; for (i=0; i<2000; i++) pbData[i] = (unsigned char)i; result = CryptCreateHash(hProv, CALG_MD2, 0, 0, &hHash); if (!result) { @@ -258,7 +270,7 @@ static BOOL derive_key(ALG_ID aiAlgid, HCRYPTKEY *phKey, DWORD len) } ok(result, "%08x\n", GetLastError()); if (!result) return FALSE; - result = CryptHashData(hHash, (BYTE*)pbData, sizeof(pbData), 0); + result = CryptHashData(hHash, pbData, sizeof(pbData), 0); ok(result, "%08x\n", GetLastError()); if (!result) return FALSE; result = CryptDeriveKey(hProv, aiAlgid, hHash, (len << 16) | CRYPT_EXPORTABLE, phKey); @@ -303,7 +315,7 @@ static void test_hashes(void) /* rsaenh compiled without OpenSSL */ ok(GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); } else { - result = CryptHashData(hHash, (BYTE*)pbData, sizeof(pbData), 0); + result = CryptHashData(hHash, pbData, sizeof(pbData), 0); ok(result, "%08x\n", GetLastError()); len = sizeof(DWORD); @@ -324,7 +336,7 @@ static void test_hashes(void) result = CryptCreateHash(hProv, CALG_MD4, 0, 0, &hHash); ok(result, "%08x\n", GetLastError()); - result = CryptHashData(hHash, (BYTE*)pbData, sizeof(pbData), 0); + result = CryptHashData(hHash, pbData, sizeof(pbData), 0); ok(result, "%08x\n", GetLastError()); len = sizeof(DWORD); @@ -348,7 +360,7 @@ static void test_hashes(void) result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0); ok(result && (hashlen == 16), "%08x, hashlen: %d\n", GetLastError(), hashlen); - result = CryptHashData(hHash, (BYTE*)pbData, sizeof(pbData), 0); + result = CryptHashData(hHash, pbData, sizeof(pbData), 0); ok(result, "%08x\n", GetLastError()); len = 16; @@ -378,8 +390,11 @@ static void test_hashes(void) /* Can't add data after the hash been retrieved */ SetLastError(0xdeadbeef); - result = CryptHashData(hHash, (BYTE*)pbData, sizeof(pbData), 0); - ok(!result && GetLastError() == NTE_BAD_HASH_STATE, "%08x\n", GetLastError()); + result = CryptHashData(hHash, pbData, sizeof(pbData), 0); + 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()); /* You can still retrieve the hash, its value just hasn't changed */ result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0); @@ -394,7 +409,7 @@ static void test_hashes(void) result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash); ok(result, "%08x\n", GetLastError()); - result = CryptHashData(hHash, (BYTE*)pbData, 5, 0); + result = CryptHashData(hHash, pbData, 5, 0); ok(result, "%08x\n", GetLastError()); if(pCryptDuplicateHash) { @@ -451,17 +466,17 @@ static void test_block_cipher_modes(void) ok(result, "%08x\n", GetLastError()); dwLen = 23; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, NULL, &dwLen, 24); + result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwLen, 24); ok(result, "CryptEncrypt failed: %08x\n", GetLastError()); ok(dwLen == 24, "Unexpected length %d\n", dwLen); SetLastError(ERROR_SUCCESS); dwLen = 23; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData, &dwLen, 24); + result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); ok(result && dwLen == 24 && !memcmp(ecb, abData, sizeof(ecb)), "%08x, dwLen: %d\n", GetLastError(), dwLen); - result = CryptDecrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData, &dwLen); + result = CryptDecrypt(hKey, 0, TRUE, 0, abData, &dwLen); ok(result && dwLen == 23 && !memcmp(plain, abData, sizeof(plain)), "%08x, dwLen: %d\n", GetLastError(), dwLen); @@ -470,16 +485,16 @@ static void test_block_cipher_modes(void) ok(result, "%08x\n", GetLastError()); dwLen = 23; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, NULL, &dwLen, 24); + result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwLen, 24); ok(result, "CryptEncrypt failed: %08x\n", GetLastError()); ok(dwLen == 24, "Unexpected length %d\n", dwLen); dwLen = 23; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData, &dwLen, 24); + result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); ok(result && dwLen == 24 && !memcmp(cbc, abData, sizeof(cbc)), "%08x, dwLen: %d\n", GetLastError(), dwLen); - result = CryptDecrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData, &dwLen); + result = CryptDecrypt(hKey, 0, TRUE, 0, abData, &dwLen); ok(result && dwLen == 23 && !memcmp(plain, abData, sizeof(plain)), "%08x, dwLen: %d\n", GetLastError(), dwLen); @@ -488,20 +503,20 @@ static void test_block_cipher_modes(void) ok(result, "%08x\n", GetLastError()); dwLen = 16; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, FALSE, 0, abData, &dwLen, 24); + result = CryptEncrypt(hKey, 0, FALSE, 0, abData, &dwLen, 24); ok(result && dwLen == 16, "%08x, dwLen: %d\n", GetLastError(), dwLen); dwLen = 7; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData+16, &dwLen, 8); + 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); dwLen = 8; - result = CryptDecrypt(hKey, (HCRYPTHASH)NULL, FALSE, 0, abData, &dwLen); + result = CryptDecrypt(hKey, 0, FALSE, 0, abData, &dwLen); ok(result && dwLen == 8, "%08x, dwLen: %d\n", GetLastError(), dwLen); dwLen = 16; - result = CryptDecrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData+8, &dwLen); + result = CryptDecrypt(hKey, 0, TRUE, 0, abData+8, &dwLen); ok(result && dwLen == 15 && !memcmp(plain, abData, sizeof(plain)), "%08x, dwLen: %d\n", GetLastError(), dwLen); @@ -510,7 +525,7 @@ static void test_block_cipher_modes(void) ok(result, "%08x\n", GetLastError()); dwLen = 23; - result = CryptEncrypt(hKey, (HCRYPTHASH)NULL, TRUE, 0, abData, &dwLen, 24); + result = CryptEncrypt(hKey, 0, TRUE, 0, abData, &dwLen, 24); ok(!result && GetLastError() == NTE_BAD_ALGID, "%08x\n", GetLastError()); CryptDestroyKey(hKey); @@ -534,10 +549,10 @@ static void test_3des112(void) for (i=0; i