12,12,16}
};
-static int win2k;
+static int win2k, nt4;
/*
* 1. Take the MD5 Hash of the container name (with an extra null byte)
hProv = (HCRYPTPROV)INVALID_HANDLE_VALUE;
/* we are using NULL as provider name for RSA_AES provider as the provider
- * names are different in Windows XP and Vista. It's different to what
+ * names are different in Windows XP and Vista. This differs from what
* is defined in the SDK on Windows XP.
* This provider is available on Windows XP, Windows 2003 and Vista. */
SetLastError(0xdeadbeef);
result = CryptGetProvParam(hProv, PP_SIG_KEYSIZE_INC, (BYTE*)&dwInc, &dwLen, 0);
if (!result && GetLastError() == NTE_BAD_TYPE)
+ {
skip("PP_SIG_KEYSIZE_INC is not supported (win9x or NT)\n");
+ nt4++;
+ }
else
ok(result && dwInc==8, "%08x, %d\n", GetLastError(), dwInc);
/* Does AES provider support salt? */
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
- ok((!result && GetLastError() == NTE_BAD_KEY) || result /* Win7 */,
- "expected NTE_BAD_KEY, got %08x\n", GetLastError());
+ todo_wine ok(result || broken(GetLastError() == NTE_BAD_KEY), /* Vista or older */
+ "Expected OK, got last error %d\n", GetLastError());
if (result)
ok(!dwLen, "unexpected salt length %d\n", dwLen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
ok(result, "%08x\n", GetLastError());
- /* Setting the salt also succeeds... */
+ /* 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());
- /* but the resulting salt length is now zero? */
dwLen = 0;
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
- ok(dwLen == 0 ||
- broken(dwLen == 11), /* Win9x/WinMe/NT4 */
- "unexpected salt length %d\n", dwLen);
+ if (BASE_PROV || STRONG_PROV)
+ ok(dwLen == 11, "expected salt length 11, got %d\n", dwLen);
+ else
+ ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %d\n", dwLen);
/* What sizes salt can I set? */
salt.pbData = pbData;
for (i=0; i<24; i++)
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
ok(result, "%08x\n", GetLastError());
- /* Setting the salt also succeeds... */
+ /* 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());
- /* but the resulting salt length is now zero? */
dwLen = 0;
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
- ok(dwLen == 0 ||
- broken(dwLen == 11), /* Win9x/WinMe/NT4 */
- "unexpected salt length %d\n", dwLen);
+ if (BASE_PROV || STRONG_PROV)
+ ok(dwLen == 11, "expected salt length 11, got %d\n", dwLen);
+ else
+ ok(dwLen == 0 || broken(nt4 && dwLen == 11), "expected salt length 0, got %d\n", dwLen);
/* What sizes salt can I set? */
salt.pbData = pbData;
for (i=0; i<24; i++)
* actual buffer. The private exponent can be omitted, its length is
* inferred from the passed-in length parameter.
*/
- dwLen = sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
- rsaPubKey->bitlen / 8 + 5 * rsaPubKey->bitlen / 16;
+ dwLen = sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) + rsaPubKey->bitlen / 2;
for (; dwLen < sizeof(abPlainPrivateKey); dwLen++)
{
result = CryptImportKey(hProv, abPlainPrivateKey, dwLen, 0, 0, &hKeyExchangeKey);
if (!result) return;
result = CryptCreateHash(hProv, CALG_SCHANNEL_MASTER_HASH, hMasterSecret, 0, &hMasterHash);
- ok (result, "%08x\n", GetLastError());
- if (!result) return;
+ ok (result ||
+ broken(!result), /* Windows 8 and greater */
+ "%08x\n", GetLastError());
+ if (!result)
+ {
+ win_skip("Broken TLS1 hash creation\n");
+ CryptDestroyKey(hRSAKey);
+ CryptDestroyKey(hMasterSecret);
+ CryptReleaseContext(hProv, 0);
+ CryptAcquireContextA(&hProv, NULL, NULL, PROV_RSA_SCHANNEL, CRYPT_DELETEKEYSET);
+ return;
+ }
/* Deriving the server write encryption key from the master hash can't
* succeed before the encryption key algorithm is set.
if(!BASE_PROV) test_key_derivation(STRONG_PROV ? "STRONG" : "ENH");
clean_up_base_environment();
}
- if (!init_base_environment(MS_ENHANCED_PROV_A, 0))
+
test_key_permissions();
test_key_initialization();
test_schannel_provider();