From 81861dddccef48ede5e675c53282ea707e7d1b33 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 13 Jan 2017 19:54:22 +0100 Subject: [PATCH] secur32/tests: Use importlib for functions available since Windows XP. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/secur32/tests/schannel.c | 200 ++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 124 deletions(-) diff --git a/dlls/secur32/tests/schannel.c b/dlls/secur32/tests/schannel.c index 4abe35e630d..4b8adc4136c 100644 --- a/dlls/secur32/tests/schannel.c +++ b/dlls/secur32/tests/schannel.c @@ -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 = pQueryCredentialsAttributesA(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 = pQueryCredentialsAttributesA(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 = pQueryCredentialsAttributesA(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])); - pFreeContextBuffer(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 = pAcquireCredentialsHandleA(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 = pQueryCredentialsAttributesA(&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 = pQueryCredentialsAttributesA(&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); - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); init_cred(&schannel_cred); schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_CLIENT; - status = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&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(pEnumerateSecurityPackagesA(&i, &package_info))) + if (SUCCEEDED(EnumerateSecurityPackagesA(&i, &package_info))) { while(i--) { @@ -330,7 +287,7 @@ static void testAcquireSecurityContext(void) break; } } - pFreeContextBuffer(package_info); + FreeContextBuffer(package_info); } if (!has_schannel) { @@ -361,55 +318,55 @@ static void testAcquireSecurityContext(void) return; } - st = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 */ - pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND, + AcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND, NULL, NULL, NULL, NULL, NULL, NULL); } - st = pAcquireCredentialsHandleA(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) - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); memset(&cred, 0, sizeof(cred)); - st = pAcquireCredentialsHandleA(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 = pQueryCredentialsAttributesA(&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); - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); /* Bad version in SCHANNEL_CRED */ memset(&schanCred, 0, sizeof(schanCred)); - st = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); /* but fails for inbound. */ - st = pAcquireCredentialsHandleA(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; - pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 */ - pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&cred); - st = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); schanCred.dwVersion = SCHANNEL_CRED_VERSION; - st = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&cred); - st = pAcquireCredentialsHandleA(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); - pFreeCredentialsHandle(&cred); + FreeCredentialsHandle(&cred); /* How about more than one cert? */ schanCred.cCreds = 2; schanCred.paCred = certs; - st = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pAcquireCredentialsHandleA(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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pInitializeSecurityContextA(&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 = pQueryCredentialsAttributesA(&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 = pEncryptMessage(&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 = pDecryptMessage(&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 = pDecryptMessage(&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 = pDecryptMessage(&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 = pDecryptMessage(&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 = pDecryptMessage(&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 = pDecryptMessage(&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; } - pDeleteSecurityContext(&context); - pFreeCredentialsHandle(&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); } -- 2.11.4.GIT