Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
81861ddd
Commit
81861ddd
authored
Jan 13, 2017
by
Jacek Caban
Committed by
Alexandre Julliard
Jan 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secur32/tests: Use importlib for functions available since Windows XP.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cb46a245
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
124 deletions
+76
-124
schannel.c
dlls/secur32/tests/schannel.c
+76
-124
No files found.
dlls/secur32/tests/schannel.c
View file @
81861ddd
...
...
@@ -29,18 +29,7 @@
#include "wine/test.h"
static
HMODULE
secdll
;
static
ACQUIRE_CREDENTIALS_HANDLE_FN_A
pAcquireCredentialsHandleA
;
static
ENUMERATE_SECURITY_PACKAGES_FN_A
pEnumerateSecurityPackagesA
;
static
FREE_CONTEXT_BUFFER_FN
pFreeContextBuffer
;
static
FREE_CREDENTIALS_HANDLE_FN
pFreeCredentialsHandle
;
static
QUERY_CREDENTIALS_ATTRIBUTES_FN_A
pQueryCredentialsAttributesA
;
static
INITIALIZE_SECURITY_CONTEXT_FN_A
pInitializeSecurityContextA
;
static
QUERY_CONTEXT_ATTRIBUTES_FN_A
pQueryContextAttributesA
;
static
DELETE_SECURITY_CONTEXT_FN
pDeleteSecurityContext
;
static
DECRYPT_MESSAGE_FN
pDecryptMessage
;
static
ENCRYPT_MESSAGE_FN
pEncryptMessage
;
static
const
BYTE
bigCert
[]
=
{
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
...
...
@@ -107,31 +96,6 @@ static const BYTE selfSignedCert[] = {
static
CHAR
unisp_name_a
[]
=
UNISP_NAME_A
;
static
void
InitFunctionPtrs
(
void
)
{
secdll
=
LoadLibraryA
(
"secur32.dll"
);
if
(
!
secdll
)
secdll
=
LoadLibraryA
(
"security.dll"
);
#define GET_PROC(h, func) p ## func = (void*)GetProcAddress(h, #func)
if
(
secdll
)
{
GET_PROC
(
secdll
,
AcquireCredentialsHandleA
);
GET_PROC
(
secdll
,
EnumerateSecurityPackagesA
);
GET_PROC
(
secdll
,
FreeContextBuffer
);
GET_PROC
(
secdll
,
FreeCredentialsHandle
);
GET_PROC
(
secdll
,
QueryCredentialsAttributesA
);
GET_PROC
(
secdll
,
InitializeSecurityContextA
);
GET_PROC
(
secdll
,
QueryContextAttributesA
);
GET_PROC
(
secdll
,
DeleteSecurityContext
);
GET_PROC
(
secdll
,
DecryptMessage
);
GET_PROC
(
secdll
,
EncryptMessage
);
}
#undef GET_PROC
}
static
const
char
*
algid_to_str
(
ALG_ID
alg
)
{
static
char
buf
[
12
];
...
...
@@ -212,7 +176,7 @@ static void test_strength(PCredHandle handle)
SecPkgCred_CipherStrengths
strength
=
{
-
1
,
-
1
};
SECURITY_STATUS
st
;
st
=
p
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_CIPHER_STRENGTHS
,
&
strength
);
st
=
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_CIPHER_STRENGTHS
,
&
strength
);
ok
(
st
==
SEC_E_OK
,
"QueryCredentialsAttributesA failed: %u
\n
"
,
GetLastError
());
ok
(
strength
.
dwMinimumCipherStrength
,
"dwMinimumCipherStrength not changed
\n
"
);
ok
(
strength
.
dwMaximumCipherStrength
,
"dwMaximumCipherStrength not changed
\n
"
);
...
...
@@ -224,7 +188,7 @@ static void test_supported_protocols(CredHandle *handle, unsigned exprots)
SecPkgCred_SupportedProtocols
protocols
;
SECURITY_STATUS
status
;
status
=
p
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_SUPPORTED_PROTOCOLS
,
&
protocols
);
status
=
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_SUPPORTED_PROTOCOLS
,
&
protocols
);
ok
(
status
==
SEC_E_OK
,
"QueryCredentialsAttributes failed: %08x
\n
"
,
status
);
if
(
exprots
)
...
...
@@ -250,7 +214,7 @@ static void test_supported_algs(CredHandle *handle)
SECURITY_STATUS
status
;
unsigned
i
;
status
=
p
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_SUPPORTED_ALGS
,
&
algs
);
status
=
QueryCredentialsAttributesA
(
handle
,
SECPKG_ATTR_SUPPORTED_ALGS
,
&
algs
);
todo_wine
ok
(
status
==
SEC_E_OK
,
"QueryCredentialsAttributes failed: %08x
\n
"
,
status
);
if
(
status
!=
SEC_E_OK
)
return
;
...
...
@@ -259,7 +223,7 @@ static void test_supported_algs(CredHandle *handle)
for
(
i
=
0
;
i
<
algs
.
cSupportedAlgs
;
i
++
)
trace
(
" %s
\n
"
,
algid_to_str
(
algs
.
palgSupportedAlgs
[
i
]));
p
FreeContextBuffer
(
algs
.
palgSupportedAlgs
);
FreeContextBuffer
(
algs
.
palgSupportedAlgs
);
}
static
void
test_cread_attrs
(
void
)
...
...
@@ -268,31 +232,31 @@ static void test_cread_attrs(void)
SECURITY_STATUS
status
;
CredHandle
cred
;
status
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
status
=
AcquireCredentialsHandleA
(
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
=
p
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_ATTR_SUPPORTED_PROTOCOLS
,
NULL
);
status
=
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_ATTR_SUPPORTED_PROTOCOLS
,
NULL
);
ok
(
status
==
SEC_E_INTERNAL_ERROR
,
"QueryCredentialsAttributes failed: %08x, expected SEC_E_INTERNAL_ERROR
\n
"
,
status
);
status
=
p
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_ATTR_SUPPORTED_ALGS
,
NULL
);
status
=
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_ATTR_SUPPORTED_ALGS
,
NULL
);
ok
(
status
==
SEC_E_INTERNAL_ERROR
,
"QueryCredentialsAttributes failed: %08x, expected SEC_E_INTERNAL_ERROR
\n
"
,
status
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
init_cred
(
&
schannel_cred
);
schannel_cred
.
grbitEnabledProtocols
=
SP_PROT_TLS1_CLIENT
;
status
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
status
=
AcquireCredentialsHandleA
(
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
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
}
static
void
testAcquireSecurityContext
(
void
)
...
...
@@ -312,15 +276,8 @@ static void testAcquireSecurityContext(void)
HCRYPTKEY
key
;
CRYPT_KEY_PROV_INFO
keyProvInfo
;
if
(
!
pAcquireCredentialsHandleA
||
!
pEnumerateSecurityPackagesA
||
!
pFreeContextBuffer
||
!
pFreeCredentialsHandle
)
{
win_skip
(
"Needed functions are not available
\n
"
);
return
;
}
if
(
SUCCEEDED
(
p
EnumerateSecurityPackagesA
(
&
i
,
&
package_info
)))
if
(
SUCCEEDED
(
EnumerateSecurityPackagesA
(
&
i
,
&
package_info
)))
{
while
(
i
--
)
{
...
...
@@ -330,7 +287,7 @@ static void testAcquireSecurityContext(void)
break
;
}
}
p
FreeContextBuffer
(
package_info
);
FreeContextBuffer
(
package_info
);
}
if
(
!
has_schannel
)
{
...
...
@@ -361,55 +318,55 @@ static void testAcquireSecurityContext(void)
return
;
}
st
=
p
AcquireCredentialsHandleA
(
NULL
,
NULL
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
st
=
AcquireCredentialsHandleA
(
NULL
,
NULL
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_SECPKG_NOT_FOUND
,
"Expected SEC_E_SECPKG_NOT_FOUND, got %08x
\n
"
,
st
);
if
(
0
)
{
/* Crashes on Win2K */
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
0
,
NULL
,
NULL
,
NULL
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_NO_CREDENTIALS
,
"Expected SEC_E_NO_CREDENTIALS, got %08x
\n
"
,
st
);
/* Crashes on WinNT */
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_BOTH
,
NULL
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_BOTH
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_NO_CREDENTIALS
,
"Expected SEC_E_NO_CREDENTIALS, got %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_NO_CREDENTIALS
,
"Expected SEC_E_NO_CREDENTIALS, got %08x
\n
"
,
st
);
/* Crashes */
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
}
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
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
)
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
memset
(
&
cred
,
0
,
sizeof
(
cred
));
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
NULL
,
NULL
,
NULL
,
&
cred
,
&
exp
);
ok
(
st
==
SEC_E_OK
,
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
/* expriy is indeterminate in win2k3 */
trace
(
"expiry: %08x%08x
\n
"
,
exp
.
HighPart
,
exp
.
LowPart
);
st
=
p
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_CRED_ATTR_NAMES
,
&
names
);
st
=
QueryCredentialsAttributesA
(
&
cred
,
SECPKG_CRED_ATTR_NAMES
,
&
names
);
ok
(
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_UNSUPPORTED_FUNCTION
/* before Vista */
,
"expected SEC_E_NO_CREDENTIALS, got %08x
\n
"
,
st
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
/* Bad version in SCHANNEL_CRED */
memset
(
&
schanCred
,
0
,
sizeof
(
schanCred
));
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
||
st
==
SEC_E_INVALID_TOKEN
/* WinNT */
,
"st = %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
||
...
...
@@ -417,12 +374,12 @@ static void testAcquireSecurityContext(void)
/* No cert in SCHANNEL_CRED succeeds for outbound.. */
schanCred
.
dwVersion
=
SCHANNEL_CRED_VERSION
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_OK
,
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
/* but fails for inbound. */
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_OK
/* Vista/win2k8 */
,
...
...
@@ -432,7 +389,7 @@ static void testAcquireSecurityContext(void)
{
/* Crashes with bad paCred pointer */
schanCred
.
cCreds
=
1
;
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
}
...
...
@@ -441,12 +398,12 @@ static void testAcquireSecurityContext(void)
*/
schanCred
.
cCreds
=
1
;
schanCred
.
paCred
=
&
certs
[
0
];
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_INVALID_TOKEN
/* WinNT */
,
"st = %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
...
...
@@ -457,13 +414,13 @@ static void testAcquireSecurityContext(void)
*/
schanCred
.
cCreds
=
1
;
schanCred
.
paCred
=
&
certs
[
1
];
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_INTERNAL_ERROR
,
/* win2k */
"Expected SEC_E_UNKNOWN_CREDENTIALS, SEC_E_NO_CREDENTIALS "
"or SEC_E_INTERNAL_ERROR, got %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_INTERNAL_ERROR
,
/* win2k */
...
...
@@ -475,11 +432,11 @@ static void testAcquireSecurityContext(void)
CERT_KEY_PROV_INFO_PROP_ID
,
0
,
&
keyProvInfo
);
schanCred
.
dwVersion
=
SCH_CRED_V3
;
ok
(
ret
,
"CertSetCertificateContextProperty failed: %08x
\n
"
,
GetLastError
());
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_INTERNAL_ERROR
/* WinNT */
,
"Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_INTERNAL_ERROR, got %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_INTERNAL_ERROR
/* WinNT */
,
"Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_INTERNAL_ERROR, got %08x
\n
"
,
st
);
...
...
@@ -498,29 +455,29 @@ static void testAcquireSecurityContext(void)
if
(
0
)
{
/* Crashes */
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
NULL
,
NULL
);
/* Crashes on WinNT */
/* Good cert with private key, bogus version */
schanCred
.
dwVersion
=
SCH_CRED_V1
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
,
"Expected SEC_E_INTERNAL_ERROR or SEC_E_UNKNOWN_CREDENTIALS, got %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
,
"Expected SEC_E_INTERNAL_ERROR or SEC_E_UNKNOWN_CREDENTIALS, got %08x
\n
"
,
st
);
schanCred
.
dwVersion
=
SCH_CRED_V2
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
,
"Expected SEC_E_INTERNAL_ERROR or SEC_E_UNKNOWN_CREDENTIALS, got %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_INTERNAL_ERROR
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
/* Vista/win2k8 */
,
...
...
@@ -529,38 +486,38 @@ static void testAcquireSecurityContext(void)
/* Succeeds on V3 or higher */
schanCred
.
dwVersion
=
SCH_CRED_V3
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_OK
,
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
p
FreeCredentialsHandle
(
&
cred
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
FreeCredentialsHandle
(
&
cred
);
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_OK
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
,
/* win2k3 */
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
schanCred
.
dwVersion
=
SCHANNEL_CRED_VERSION
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_OK
,
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
p
FreeCredentialsHandle
(
&
cred
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
FreeCredentialsHandle
(
&
cred
);
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_OK
||
st
==
SEC_E_UNKNOWN_CREDENTIALS
,
/* win2k3 */
"AcquireCredentialsHandleA failed: %08x
\n
"
,
st
);
if
(
st
==
SEC_E_OK
)
test_strength
(
&
cred
);
p
FreeCredentialsHandle
(
&
cred
);
FreeCredentialsHandle
(
&
cred
);
/* How about more than one cert? */
schanCred
.
cCreds
=
2
;
schanCred
.
paCred
=
certs
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
/* Vista/win2k8 */
||
st
==
SEC_E_INVALID_TOKEN
/* WinNT */
,
"st = %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
...
...
@@ -568,12 +525,12 @@ static void testAcquireSecurityContext(void)
tmp
=
certs
[
0
];
certs
[
0
]
=
certs
[
1
];
certs
[
1
]
=
tmp
;
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_OUTBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
||
st
==
SEC_E_NO_CREDENTIALS
||
st
==
SEC_E_INVALID_TOKEN
/* WinNT */
,
"st = %08x
\n
"
,
st
);
st
=
p
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
st
=
AcquireCredentialsHandleA
(
NULL
,
unisp_name_a
,
SECPKG_CRED_INBOUND
,
NULL
,
&
schanCred
,
NULL
,
NULL
,
&
cred
,
NULL
);
ok
(
st
==
SEC_E_UNKNOWN_CREDENTIALS
,
"Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x
\n
"
,
st
);
...
...
@@ -705,11 +662,9 @@ static void test_communication(void)
unsigned
char
*
data
;
unsigned
data_size
;
if
(
!
pAcquireCredentialsHandleA
||
!
pFreeCredentialsHandle
||
!
pInitializeSecurityContextA
||
!
pDeleteSecurityContext
||
!
pQueryContextAttributesA
||
!
pDecryptMessage
||
!
pEncryptMessage
)
if
(
!
pQueryContextAttributesA
)
{
skip
(
"Required secur32 functions not available
\n
"
);
win_
skip
(
"Required secur32 functions not available
\n
"
);
return
;
}
...
...
@@ -750,7 +705,7 @@ static void test_communication(void)
cred
.
grbitEnabledProtocols
=
SP_PROT_TLS1_CLIENT
;
cred
.
dwFlags
=
SCH_CRED_NO_DEFAULT_CREDS
|
SCH_CRED_MANUAL_CRED_VALIDATION
;
status
=
p
AcquireCredentialsHandleA
(
NULL
,
(
SEC_CHAR
*
)
UNISP_NAME_A
,
SECPKG_CRED_OUTBOUND
,
NULL
,
status
=
AcquireCredentialsHandleA
(
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
;
...
...
@@ -760,7 +715,7 @@ static void test_communication(void)
init_buffers
(
&
buffers
[
1
],
4
,
buf_size
);
buffers
[
0
].
pBuffers
[
0
].
BufferType
=
SECBUFFER_TOKEN
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
NULL
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
NULL
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
NULL
,
0
,
&
context
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_I_CONTINUE_NEEDED
,
"Expected SEC_I_CONTINUE_NEEDED, got %08x
\n
"
,
status
);
...
...
@@ -769,7 +724,7 @@ static void test_communication(void)
buffers
[
1
].
pBuffers
[
0
].
BufferType
=
SECBUFFER_TOKEN
;
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
1
;
memset
(
buffers
[
1
].
pBuffers
[
0
].
pvBuffer
,
0xfa
,
buf_size
);
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
todo_wine
...
...
@@ -781,7 +736,7 @@ todo_wine
buffers
[
1
].
pBuffers
[
0
].
BufferType
=
SECBUFFER_TOKEN
;
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
1
;
memset
(
buffers
[
1
].
pBuffers
[
0
].
pvBuffer
,
0
,
buf_size
);
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_E_INVALID_TOKEN
,
"Expected SEC_E_INVALID_TOKEN, got %08x
\n
"
,
status
);
...
...
@@ -789,7 +744,7 @@ todo_wine
ok
(
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
==
0
,
"Output buffer size was not set to 0.
\n
"
);
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
0
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
todo_wine
...
...
@@ -798,7 +753,7 @@ todo_wine
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
buf_size
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
NULL
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
NULL
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
NULL
,
0
,
&
context
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_I_CONTINUE_NEEDED
,
"Expected SEC_I_CONTINUE_NEEDED, got %08x
\n
"
,
status
);
...
...
@@ -807,7 +762,7 @@ todo_wine
send
(
sock
,
buf
->
pvBuffer
,
buf
->
cbBuffer
,
0
);
buf
->
cbBuffer
=
buf_size
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
NULL
,
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_E_INCOMPLETE_MESSAGE
,
"Got unexpected status %#x.
\n
"
,
status
);
...
...
@@ -817,7 +772,7 @@ todo_wine
buffers
[
1
].
cBuffers
=
4
;
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
0
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_E_INCOMPLETE_MESSAGE
,
"Got unexpected status %#x.
\n
"
,
status
);
...
...
@@ -831,7 +786,7 @@ todo_wine
return
;
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
4
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_E_INCOMPLETE_MESSAGE
,
"Got unexpected status %#x.
\n
"
,
status
);
...
...
@@ -839,7 +794,7 @@ todo_wine
ok
(
buffers
[
0
].
pBuffers
[
0
].
BufferType
==
SECBUFFER_TOKEN
,
"Output buffer type changed.
\n
"
);
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
5
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
ok
(
status
==
SEC_E_INCOMPLETE_MESSAGE
,
"Got unexpected status %#x.
\n
"
,
status
);
...
...
@@ -847,7 +802,7 @@ todo_wine
ok
(
buffers
[
0
].
pBuffers
[
0
].
BufferType
==
SECBUFFER_TOKEN
,
"Output buffer type changed.
\n
"
);
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
ret
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
buf_size
;
...
...
@@ -864,7 +819,7 @@ todo_wine
buf
->
BufferType
=
SECBUFFER_TOKEN
;
status
=
p
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
status
=
InitializeSecurityContextA
(
&
cred_handle
,
&
context
,
(
SEC_CHAR
*
)
"localhost"
,
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_STREAM
,
0
,
0
,
&
buffers
[
1
],
0
,
NULL
,
&
buffers
[
0
],
&
attrs
,
NULL
);
buffers
[
1
].
pBuffers
[
0
].
cbBuffer
=
buf_size
;
...
...
@@ -877,7 +832,7 @@ todo_wine
return
;
}
status
=
p
QueryCredentialsAttributesA
(
&
cred_handle
,
SECPKG_CRED_ATTR_NAMES
,
&
names
);
status
=
QueryCredentialsAttributesA
(
&
cred_handle
,
SECPKG_CRED_ATTR_NAMES
,
&
names
);
ok
(
status
==
SEC_E_NO_CREDENTIALS
||
status
==
SEC_E_UNSUPPORTED_FUNCTION
/* before Vista */
,
"expected SEC_E_NO_CREDENTIALS, got %08x
\n
"
,
status
);
status
=
pQueryContextAttributesA
(
&
context
,
SECPKG_ATTR_REMOTE_CERT_CONTEXT
,
(
void
*
)
&
cert
);
...
...
@@ -914,7 +869,7 @@ todo_wine
buf
->
pvBuffer
=
data
+
sizes
.
cbHeader
+
sizeof
(
http_request
)
-
1
;
buf
->
cbBuffer
=
sizes
.
cbTrailer
;
status
=
p
EncryptMessage
(
&
context
,
0
,
&
buffers
[
0
],
0
);
status
=
EncryptMessage
(
&
context
,
0
,
&
buffers
[
0
],
0
);
ok
(
status
==
SEC_E_OK
,
"EncryptMessage failed: %08x
\n
"
,
status
);
if
(
status
!=
SEC_E_OK
)
return
;
...
...
@@ -928,29 +883,29 @@ todo_wine
/* Too few buffers */
--
buffers
[
0
].
cBuffers
;
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_INVALID_TOKEN
,
"Expected SEC_E_INVALID_TOKEN, got %08x
\n
"
,
status
);
/* No data buffer */
++
buffers
[
0
].
cBuffers
;
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_INVALID_TOKEN
,
"Expected SEC_E_INVALID_TOKEN, got %08x
\n
"
,
status
);
/* Two data buffers */
buffers
[
0
].
pBuffers
[
0
].
BufferType
=
SECBUFFER_DATA
;
buffers
[
0
].
pBuffers
[
1
].
BufferType
=
SECBUFFER_DATA
;
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_INVALID_TOKEN
,
"Expected SEC_E_INVALID_TOKEN, got %08x
\n
"
,
status
);
/* Too few empty buffers */
buffers
[
0
].
pBuffers
[
1
].
BufferType
=
SECBUFFER_EXTRA
;
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_INVALID_TOKEN
,
"Expected SEC_E_INVALID_TOKEN, got %08x
\n
"
,
status
);
/* Incomplete data */
buffers
[
0
].
pBuffers
[
1
].
BufferType
=
SECBUFFER_EMPTY
;
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
(
data
[
3
]
<<
8
)
|
data
[
4
];
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_INCOMPLETE_MESSAGE
,
"Expected SEC_E_INCOMPLETE_MESSAGE, got %08x
\n
"
,
status
);
ok
(
buffers
[
0
].
pBuffers
[
0
].
BufferType
==
SECBUFFER_MISSING
,
"Expected first buffer to be SECBUFFER_MISSING
\n
"
);
ok
(
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
==
5
,
"Expected first buffer to be a five bytes
\n
"
);
...
...
@@ -958,7 +913,7 @@ todo_wine
buffers
[
0
].
pBuffers
[
0
].
cbBuffer
=
data_size
;
buffers
[
0
].
pBuffers
[
0
].
BufferType
=
SECBUFFER_DATA
;
buffers
[
0
].
pBuffers
[
1
].
BufferType
=
SECBUFFER_EMPTY
;
status
=
p
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
status
=
DecryptMessage
(
&
context
,
&
buffers
[
0
],
0
,
NULL
);
ok
(
status
==
SEC_E_OK
,
"DecryptMessage failed: %08x
\n
"
,
status
);
if
(
status
==
SEC_E_OK
)
{
...
...
@@ -970,8 +925,8 @@ todo_wine
data
[
buffers
[
0
].
pBuffers
[
1
].
cbBuffer
]
=
0
;
}
p
DeleteSecurityContext
(
&
context
);
p
FreeCredentialsHandle
(
&
cred_handle
);
DeleteSecurityContext
(
&
context
);
FreeCredentialsHandle
(
&
cred_handle
);
free_buffers
(
&
buffers
[
0
]);
free_buffers
(
&
buffers
[
1
]);
...
...
@@ -981,12 +936,9 @@ todo_wine
START_TEST
(
schannel
)
{
InitFunctionPtrs
(
);
pQueryContextAttributesA
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"secur32.dll"
),
"QueryContextAttributesA"
);
test_cread_attrs
();
testAcquireSecurityContext
();
test_communication
();
if
(
secdll
)
FreeLibrary
(
secdll
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment