3#include <winpr/winpr.h>
4#include <winpr/tchar.h>
5#include <winpr/credssp.h>
6#include <winpr/schannel.h>
14static int test_query_package(
void)
18 if (!table || !table->QuerySecurityPackageInfoW)
20 (void)fprintf(stderr,
"no WinPR security function table\n");
24 WCHAR name[] = {
'T',
'S',
'S',
'S',
'P',
'\0' };
25 const SECURITY_STATUS status = table->QuerySecurityPackageInfoW(name, &info);
26 if (status != SEC_E_OK)
28 (void)fprintf(stderr,
"QuerySecurityPackageInfoW(TSSSP) failed: 0x%08" PRIx32
"\n",
34 if (!info || !info->Name || (_wcscmp(info->Name, name) != 0))
36 (void)fprintf(stderr,
"QuerySecurityPackageInfoW(TSSSP) returned an unexpected name\n");
40 if (table->FreeContextBuffer)
41 (void)table->FreeContextBuffer(info);
45#if defined(_WIN32) && !defined(_UWP)
46static void test_acquire_credentials(
void)
49 if (!table || !table->AcquireCredentialsHandleW || !table->FreeCredentialsHandle)
53 sc.dwVersion = SCH_CREDENTIALS_VERSION;
56 cred.Type = CredsspSubmitBufferBothOld;
57 cred.pSchannelCred = ≻
58 cred.pSpnegoCred =
nullptr;
61 credEx.Type = (CREDSPP_SUBMIT_TYPE)CredsspCredEx;
62 credEx.Version = CREDSSP_CRED_EX_VERSION;
63 credEx.Flags = CREDSSP_FLAG_REDIRECT;
66 WCHAR pkg[] = {
'T',
'S',
'S',
'S',
'P',
'\0' };
67 CredHandle handle = WINPR_C_ARRAY_INIT;
68 TimeStamp expiry = WINPR_C_ARRAY_INIT;
69 const SECURITY_STATUS status = table->AcquireCredentialsHandleW(
70 nullptr, pkg, SECPKG_CRED_OUTBOUND,
nullptr, &credEx,
nullptr,
nullptr, &handle, &expiry);
72 (void)fprintf(stderr,
"AcquireCredentialsHandleW(TSSSP) returned 0x%08" PRIx32
"\n",
74 if (status == SEC_E_OK)
75 (void)table->FreeCredentialsHandle(&handle);
79int TestSspiTSSSP(
int argc,
char* argv[])
86 int rc = test_query_package();
88#if defined(_WIN32) && !defined(_UWP)
90 test_acquire_credentials();