Author: akhaldi
Date: Thu Nov 26 23:32:19 2015
New Revision: 70137
URL:
http://svn.reactos.org/svn/reactos?rev=70137&view=rev
Log:
[SECUR32_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
Modified:
trunk/rostests/winetests/secur32/negotiate.c
trunk/rostests/winetests/secur32/schannel.c
trunk/rostests/winetests/secur32/secur32.c
Modified: trunk/rostests/winetests/secur32/negotiate.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/secur32/negotia…
==============================================================================
--- trunk/rostests/winetests/secur32/negotiate.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/secur32/negotiate.c [iso-8859-1] Thu Nov 26 23:32:19 2015
@@ -262,6 +262,9 @@
SecPkgInfoA *pi;
BOOL first = TRUE;
+ memset(&client, 0, sizeof(client));
+ memset(&server, 0, sizeof(server));
+
id.User = (unsigned char *)"user";
id.UserLength = strlen( "user" );
id.Domain = (unsigned char *)"domain";
@@ -342,17 +345,29 @@
cleanup_buffers( &client );
cleanup_buffers( &server );
- status_c = pDeleteSecurityContext( &client.ctxt );
- ok( status_c == SEC_E_OK, "DeleteSecurityContext returned %08x\n", status_c
);
-
- status_s = pDeleteSecurityContext( &server.ctxt );
- ok( status_s == SEC_E_OK, "DeleteSecurityContext returned %08x\n", status_s
);
-
- status_c = pFreeCredentialsHandle( &client.cred );
- ok( status_c == SEC_E_OK, "FreeCredentialsHandle returned %08x\n", status_c
);
-
- status_s = pFreeCredentialsHandle(&server.cred);
- ok( status_s == SEC_E_OK, "FreeCredentialsHandle returned %08x\n", status_s
);
+ if (client.ctxt.dwLower || client.ctxt.dwUpper)
+ {
+ status_c = pDeleteSecurityContext( &client.ctxt );
+ ok( status_c == SEC_E_OK, "DeleteSecurityContext returned %08x\n",
status_c );
+ }
+
+ if (server.ctxt.dwLower || server.ctxt.dwUpper)
+ {
+ status_s = pDeleteSecurityContext( &server.ctxt );
+ ok( status_s == SEC_E_OK, "DeleteSecurityContext returned %08x\n",
status_s );
+ }
+
+ if (client.cred.dwLower || client.cred.dwUpper)
+ {
+ status_c = pFreeCredentialsHandle( &client.cred );
+ ok( status_c == SEC_E_OK, "FreeCredentialsHandle returned %08x\n",
status_c );
+ }
+
+ if (server.cred.dwLower || server.cred.dwUpper)
+ {
+ status_s = pFreeCredentialsHandle(&server.cred);
+ ok( status_s == SEC_E_OK, "FreeCredentialsHandle returned %08x\n",
status_s );
+ }
}
START_TEST(negotiate)
Modified: trunk/rostests/winetests/secur32/schannel.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/secur32/schanne…
==============================================================================
--- trunk/rostests/winetests/secur32/schannel.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/secur32/schannel.c [iso-8859-1] Thu Nov 26 23:32:19 2015
@@ -115,6 +115,8 @@
0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f,
0xa8, 0x76, 0x57, 0x92, 0x36 };
+static CHAR unisp_name_a[] = UNISP_NAME_A;
+
static void InitFunctionPtrs(void)
{
HMODULE advapi32dll;
@@ -154,6 +156,81 @@
#undef GET_PROC
}
+static const char *algid_to_str(ALG_ID alg)
+{
+ static char buf[12];
+ switch(alg) {
+#define X(x) case x: return #x
+ X(CALG_MD2);
+ X(CALG_MD4);
+ X(CALG_MD5);
+ X(CALG_SHA1); /* same as CALG_SHA */
+ X(CALG_MAC);
+ X(CALG_RSA_SIGN);
+ X(CALG_DSS_SIGN);
+ X(CALG_NO_SIGN);
+ X(CALG_RSA_KEYX);
+ X(CALG_DES);
+ X(CALG_3DES_112);
+ X(CALG_3DES);
+ X(CALG_DESX);
+ X(CALG_RC2);
+ X(CALG_RC4);
+ X(CALG_SEAL);
+ X(CALG_DH_SF);
+ X(CALG_DH_EPHEM);
+ X(CALG_AGREEDKEY_ANY);
+ X(CALG_KEA_KEYX);
+ X(CALG_HUGHES_MD5);
+ X(CALG_SKIPJACK);
+ X(CALG_TEK);
+ X(CALG_CYLINK_MEK);
+ X(CALG_SSL3_SHAMD5);
+ X(CALG_SSL3_MASTER);
+ X(CALG_SCHANNEL_MASTER_HASH);
+ X(CALG_SCHANNEL_MAC_KEY);
+ X(CALG_SCHANNEL_ENC_KEY);
+ X(CALG_PCT1_MASTER);
+ X(CALG_SSL2_MASTER);
+ X(CALG_TLS1_MASTER);
+ X(CALG_RC5);
+ X(CALG_HMAC);
+ X(CALG_TLS1PRF);
+ X(CALG_HASH_REPLACE_OWF);
+ X(CALG_AES_128);
+ X(CALG_AES_192);
+ X(CALG_AES_256);
+ X(CALG_AES);
+ X(CALG_SHA_256);
+ X(CALG_SHA_384);
+ X(CALG_SHA_512);
+ X(CALG_ECDH);
+ X(CALG_ECMQV);
+ X(CALG_ECDSA);
+#undef X
+ }
+
+ sprintf(buf, "%x", alg);
+ return buf;
+}
+
+static void init_cred(SCHANNEL_CRED *cred)
+{
+ cred->dwVersion = SCHANNEL_CRED_VERSION;
+ cred->cCreds = 0;
+ cred->paCred = 0;
+ cred->hRootStore = NULL;
+ cred->cMappers = 0;
+ cred->aphMappers = NULL;
+ cred->cSupportedAlgs = 0;
+ cred->palgSupportedAlgs = NULL;
+ cred->grbitEnabledProtocols = 0;
+ cred->dwMinimumCipherStrength = 0;
+ cred->dwMaximumCipherStrength = 0;
+ cred->dwSessionLifespan = 0;
+ cred->dwFlags = 0;
+}
+
static void test_strength(PCredHandle handle)
{
SecPkgCred_CipherStrengths strength = {-1,-1};
@@ -189,6 +266,57 @@
if(protocols.grbitProtocol)
trace("Unknown flags: %x\n", protocols.grbitProtocol);
+}
+
+static void test_supported_algs(CredHandle *handle)
+{
+ SecPkgCred_SupportedAlgs algs;
+ SECURITY_STATUS status;
+ unsigned i;
+
+ status = pQueryCredentialsAttributesA(handle, SECPKG_ATTR_SUPPORTED_ALGS,
&algs);
+ todo_wine ok(status == SEC_E_OK, "QueryCredentialsAttributes failed:
%08x\n", status);
+ if(status != SEC_E_OK)
+ return;
+
+ trace("Supported algorithms (%d):\n", algs.cSupportedAlgs);
+ for(i=0; i < algs.cSupportedAlgs; i++)
+ trace(" %s\n", algid_to_str(algs.palgSupportedAlgs[i]));
+
+ pFreeContextBuffer(algs.palgSupportedAlgs);
+}
+
+static void test_cread_attrs(void)
+{
+ SCHANNEL_CRED schannel_cred;
+ SECURITY_STATUS status;
+ CredHandle cred;
+
+ status = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
+ NULL, NULL, NULL, NULL, &cred, NULL);
+ ok(status == SEC_E_OK, "AcquireCredentialsHandleA failed: %x\n", status);
+
+ test_supported_protocols(&cred, 0);
+ test_supported_algs(&cred);
+
+ status = pQueryCredentialsAttributesA(&cred, SECPKG_ATTR_SUPPORTED_PROTOCOLS,
NULL);
+ ok(status == SEC_E_INTERNAL_ERROR, "QueryCredentialsAttributes failed: %08x,
expected SEC_E_INTERNAL_ERROR\n", status);
+
+ status = pQueryCredentialsAttributesA(&cred, SECPKG_ATTR_SUPPORTED_ALGS, NULL);
+ ok(status == SEC_E_INTERNAL_ERROR, "QueryCredentialsAttributes failed: %08x,
expected SEC_E_INTERNAL_ERROR\n", status);
+
+ pFreeCredentialsHandle(&cred);
+
+ init_cred(&schannel_cred);
+ schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_CLIENT;
+ status = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
+ NULL, &schannel_cred, NULL, NULL, &cred, NULL);
+ ok(status == SEC_E_OK, "AcquireCredentialsHandleA failed: %x\n", status);
+
+ test_supported_protocols(&cred, SP_PROT_TLS1_CLIENT);
+ test_supported_algs(&cred);
+
+ pFreeCredentialsHandle(&cred);
}
static void testAcquireSecurityContext(void)
@@ -203,7 +331,6 @@
SCHANNEL_CRED schanCred;
PCCERT_CONTEXT certs[2];
HCRYPTPROV csp;
- static CHAR unisp_name_a[] = UNISP_NAME_A;
WCHAR ms_def_prov_w[MAX_PATH];
BOOL ret;
HCRYPTKEY key;
@@ -287,13 +414,8 @@
st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
NULL, NULL, NULL, NULL, &cred, NULL);
ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
- if(st == SEC_E_OK) {
- st = pQueryCredentialsAttributesA(&cred, SECPKG_ATTR_SUPPORTED_PROTOCOLS,
NULL);
- ok(st == SEC_E_INTERNAL_ERROR, "QueryCredentialsAttributes failed: %08x,
expected SEC_E_INTERNAL_ERROR\n", st);
-
- test_supported_protocols(&cred, 0);
+ if(st == SEC_E_OK)
pFreeCredentialsHandle(&cred);
- }
memset(&cred, 0, sizeof(cred));
st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
NULL, NULL, NULL, NULL, &cred, &exp);
@@ -524,23 +646,6 @@
static const char http_request[] = "HEAD /test.html HTTP/1.1\r\nHost:
www.winehq.org\r\nConnection: close\r\n\r\n";
-static void init_cred(SCHANNEL_CRED *cred)
-{
- cred->dwVersion = SCHANNEL_CRED_VERSION;
- cred->cCreds = 0;
- cred->paCred = 0;
- cred->hRootStore = NULL;
- cred->cMappers = 0;
- cred->aphMappers = NULL;
- cred->cSupportedAlgs = 0;
- cred->palgSupportedAlgs = NULL;
- cred->grbitEnabledProtocols = SP_PROT_TLS1_CLIENT;
- cred->dwMinimumCipherStrength = 0;
- cred->dwMaximumCipherStrength = 0;
- cred->dwSessionLifespan = 0;
- cred->dwFlags = 0;
-}
-
static void init_buffers(SecBufferDesc *desc, unsigned count, unsigned size)
{
desc->ulVersion = SECBUFFER_VERSION;
@@ -679,14 +784,13 @@
/* Create client credentials */
init_cred(&cred);
+ cred.grbitEnabledProtocols = SP_PROT_TLS1_CLIENT;
cred.dwFlags = SCH_CRED_NO_DEFAULT_CREDS|SCH_CRED_MANUAL_CRED_VALIDATION;
status = pAcquireCredentialsHandleA(NULL, (SEC_CHAR *)UNISP_NAME_A,
SECPKG_CRED_OUTBOUND, NULL,
&cred, NULL, NULL, &cred_handle, NULL);
ok(status == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n",
status);
if (status != SEC_E_OK) return;
-
- test_supported_protocols(&cred_handle, SP_PROT_TLS1_CLIENT);
/* Initialize the connection */
init_buffers(&buffers[0], 4, buf_size);
@@ -917,6 +1021,7 @@
{
InitFunctionPtrs();
+ test_cread_attrs();
testAcquireSecurityContext();
test_communication();
Modified: trunk/rostests/winetests/secur32/secur32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/secur32/secur32…
==============================================================================
--- trunk/rostests/winetests/secur32/secur32.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/secur32/secur32.c [iso-8859-1] Thu Nov 26 23:32:19 2015
@@ -30,6 +30,17 @@
static HMODULE secdll;
+static SECURITY_STATUS (SEC_ENTRY *pSspiEncodeAuthIdentityAsStrings)
+ (PSEC_WINNT_AUTH_IDENTITY_OPAQUE, PCWSTR *, PCWSTR *, PCWSTR *);
+static SECURITY_STATUS (SEC_ENTRY *pSspiEncodeStringsAsAuthIdentity)
+ (PCWSTR, PCWSTR, PCWSTR, PSEC_WINNT_AUTH_IDENTITY_OPAQUE *);
+static void (SEC_ENTRY *pSspiFreeAuthIdentity)
+ (PSEC_WINNT_AUTH_IDENTITY_OPAQUE);
+static void (SEC_ENTRY *pSspiLocalFree)
+ (void *);
+static void (SEC_ENTRY *pSspiZeroAuthIdentity)
+ (PSEC_WINNT_AUTH_IDENTITY_OPAQUE);
+
static BOOLEAN (WINAPI * pGetComputerObjectNameA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR
lpNameBuffer, PULONG lpnSize);
static BOOLEAN (WINAPI * pGetComputerObjectNameW)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR
lpNameBuffer, PULONG lpnSize);
static BOOLEAN (WINAPI * pGetUserNameExA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR
lpNameBuffer, PULONG lpnSize);
@@ -220,6 +231,90 @@
ok(sftW->Reserved4 == sftW->DecryptMessage, "Reserved4 should be equal to
DecryptMessage in the security function table\n");
}
+static void test_SspiEncodeStringsAsAuthIdentity(void)
+{
+ static const WCHAR username[] =
{'u','s','e','r','n','a','m','e',0};
+ static const WCHAR domainname[] =
{'d','o','m','a','i','n','n','a','m','e',0};
+ static const WCHAR password[] =
{'p','a','s','s','w','o','r','d',0};
+ const WCHAR *username_ptr, *domainname_ptr, *password_ptr;
+ PSEC_WINNT_AUTH_IDENTITY_OPAQUE id;
+ SECURITY_STATUS status;
+
+ if (!pSspiEncodeStringsAsAuthIdentity)
+ {
+ win_skip( "SspiEncodeAuthIdentityAsStrings not exported by
secur32.dll\n" );
+ return;
+ }
+
+ status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, NULL, NULL );
+ ok( status == SEC_E_INVALID_TOKEN, "got %08x\n", status );
+
+ id = (PSEC_WINNT_AUTH_IDENTITY_OPAQUE)0xdeadbeef;
+ status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, NULL, &id );
+ ok( status == SEC_E_INVALID_TOKEN, "got %08x\n", status );
+ ok( id == (PSEC_WINNT_AUTH_IDENTITY_OPAQUE)0xdeadbeef, "id set\n" );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( NULL, NULL, password, &id );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+ pSspiFreeAuthIdentity( id );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( NULL, domainname, password, &id );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+ pSspiFreeAuthIdentity( id );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( username, NULL, password, &id );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+ pSspiFreeAuthIdentity( id );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( username, NULL, NULL, &id );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+ pSspiFreeAuthIdentity( id );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( username, domainname, password, &id
);
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+
+ username_ptr = domainname_ptr = password_ptr = NULL;
+ status = pSspiEncodeAuthIdentityAsStrings( id, &username_ptr,
&domainname_ptr, &password_ptr );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( !lstrcmpW( username, username_ptr ), "wrong username\n" );
+ ok( !lstrcmpW( domainname, domainname_ptr ), "wrong domainname\n" );
+ ok( !lstrcmpW( password, password_ptr ), "wrong password\n" );
+
+ pSspiZeroAuthIdentity( id );
+
+ pSspiLocalFree( (void *)username_ptr );
+ pSspiLocalFree( (void *)domainname_ptr );
+ pSspiLocalFree( (void *)password_ptr );
+ pSspiFreeAuthIdentity( id );
+
+ id = NULL;
+ status = pSspiEncodeStringsAsAuthIdentity( username, NULL, password, &id );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( id != NULL, "id not set\n" );
+
+ username_ptr = password_ptr = NULL;
+ domainname_ptr = (const WCHAR *)0xdeadbeef;
+ status = pSspiEncodeAuthIdentityAsStrings( id, &username_ptr,
&domainname_ptr, &password_ptr );
+ ok( status == SEC_E_OK, "got %08x\n", status );
+ ok( !lstrcmpW( username, username_ptr ), "wrong username\n" );
+ ok( domainname_ptr == NULL, "domainname_ptr not cleared\n" );
+ ok( !lstrcmpW( password, password_ptr ), "wrong password\n" );
+
+ pSspiLocalFree( (void *)username_ptr );
+ pSspiLocalFree( (void *)password_ptr );
+ pSspiFreeAuthIdentity( id );
+}
+
START_TEST(secur32)
{
secdll = LoadLibraryA("secur32.dll");
@@ -229,6 +324,11 @@
if (secdll)
{
+ pSspiEncodeAuthIdentityAsStrings = (void *)GetProcAddress(secdll,
"SspiEncodeAuthIdentityAsStrings");
+ pSspiEncodeStringsAsAuthIdentity = (void *)GetProcAddress(secdll,
"SspiEncodeStringsAsAuthIdentity");
+ pSspiFreeAuthIdentity = (void *)GetProcAddress(secdll,
"SspiFreeAuthIdentity");
+ pSspiLocalFree = (void *)GetProcAddress(secdll, "SspiLocalFree");
+ pSspiZeroAuthIdentity = (void *)GetProcAddress(secdll,
"SspiZeroAuthIdentity");
pGetComputerObjectNameA = (PVOID)GetProcAddress(secdll,
"GetComputerObjectNameA");
pGetComputerObjectNameW = (PVOID)GetProcAddress(secdll,
"GetComputerObjectNameW");
pGetUserNameExA = (PVOID)GetProcAddress(secdll, "GetUserNameExA");
@@ -257,6 +357,7 @@
win_skip("GetUserNameExW not exported by secur32.dll\n");
test_InitSecurityInterface();
+ test_SspiEncodeStringsAsAuthIdentity();
FreeLibrary(secdll);
}