secur32: Implement QueryContextAttributes. Add tests.

oldstable
Kai Blin 2006-06-16 06:59:48 +00:00 committed by Alexandre Julliard
parent f1b1fe63f6
commit 9d5e09d748
2 changed files with 62 additions and 15 deletions

View File

@ -31,7 +31,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
#define NTLM_MAX_BUF 2010
#define NTLM_MAX_BUF 1904
/***********************************************************************
@ -935,22 +935,42 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContex
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext,
unsigned long ulAttribute, void *pBuffer)
{
SECURITY_STATUS ret;
/* FIXME: From reading wrapper.h, I think the dwUpper part of a context is
* the SecurePackage part and the dwLower part is the actual context
* handle. It should be easy to extract the context attributes from that.
*/
TRACE("%p %ld %p\n", phContext, ulAttribute, pBuffer);
if (phContext)
if (!phContext)
return SEC_E_INVALID_HANDLE;
switch(ulAttribute)
{
ret = SEC_E_UNSUPPORTED_FUNCTION;
#define _x(x) case (x) : FIXME(#x" stub\n"); break
_x(SECPKG_ATTR_ACCESS_TOKEN);
_x(SECPKG_ATTR_AUTHORITY);
_x(SECPKG_ATTR_DCE_INFO);
_x(SECPKG_ATTR_FLAGS);
_x(SECPKG_ATTR_KEY_INFO);
_x(SECPKG_ATTR_LIFESPAN);
_x(SECPKG_ATTR_NAMES);
_x(SECPKG_ATTR_NATIVE_NAMES);
_x(SECPKG_ATTR_NEGOTIATION_INFO);
_x(SECPKG_ATTR_PACKAGE_INFO);
_x(SECPKG_ATTR_PASSWORD_EXPIRY);
_x(SECPKG_ATTR_SESSION_KEY);
case SECPKG_ATTR_SIZES:
{
PSecPkgContext_Sizes spcs = (PSecPkgContext_Sizes)pBuffer;
spcs->cbMaxToken = NTLM_MAX_BUF;
spcs->cbMaxSignature = 16;
spcs->cbBlockSize = 1;
spcs->cbSecurityTrailer = 16;
return SEC_E_OK;
}
_x(SECPKG_ATTR_STREAM_SIZES);
_x(SECPKG_ATTR_TARGET_INFORMATION);
#undef _x
default:
TRACE("Unknown value %ld passed for ulAttribute\n", ulAttribute);
}
else
{
ret = SEC_E_INVALID_HANDLE;
}
return ret;
return SEC_E_UNSUPPORTED_FUNCTION;
}
/***********************************************************************

View File

@ -46,6 +46,7 @@ static SECURITY_STATUS (SEC_ENTRY * pAcceptSecurityContext)(PCredHandle, PCtxtHa
PULONG, PTimeStamp);
static SECURITY_STATUS (SEC_ENTRY * pFreeCredentialsHandle)(PCredHandle);
static SECURITY_STATUS (SEC_ENTRY * pDeleteSecurityContext)(PCtxtHandle);
static SECURITY_STATUS (SEC_ENTRY * pQueryContextAttributesA)(PCtxtHandle, ULONG, PVOID);
typedef struct _SspiData {
PCredHandle cred;
@ -77,6 +78,7 @@ void InitFunctionPtrs(void)
pAcceptSecurityContext = (PVOID)GetProcAddress(secdll, "AcceptSecurityContext");
pFreeCredentialsHandle = (PVOID)GetProcAddress(secdll, "FreeCredentialsHandle");
pDeleteSecurityContext = (PVOID)GetProcAddress(secdll, "DeleteSecurityContext");
pQueryContextAttributesA = (PVOID)GetProcAddress(secdll, "QueryContextAttributesA");
}
}
@ -554,6 +556,7 @@ void testAuth(SEC_CHAR* sec_pkg_name, ULONG data_rep)
BOOL first = TRUE;
SspiData client, server;
SEC_WINNT_AUTH_IDENTITY id;
SecPkgContext_Sizes ctxt_sizes;
if(setupPackageA(sec_pkg_name, &pkg_info) == SEC_E_OK)
{
@ -611,7 +614,31 @@ void testAuth(SEC_CHAR* sec_pkg_name, ULONG data_rep)
trace("Looping\n");
first = FALSE;
}
if(!strcmp(sec_pkg_name, "NTLM"))
{
sec_status = pQueryContextAttributesA(server.ctxt,
SECPKG_ATTR_SIZES, &ctxt_sizes);
ok(sec_status == SEC_E_OK,
"pQueryContextAttributesA(SECPKG_ATTR_SIZES) returned %s\n",
getSecError(sec_status));
ok(ctxt_sizes.cbMaxToken == 1904,
"cbMaxToken should be 1904 but is %lu\n",
ctxt_sizes.cbMaxToken);
ok(ctxt_sizes.cbMaxSignature == 16,
"cbMaxSignature should be 16 but is %lu\n",
ctxt_sizes.cbMaxSignature);
ok(ctxt_sizes.cbSecurityTrailer == 16,
"cbSecurityTrailer should be 16 but is %lu\n",
ctxt_sizes.cbSecurityTrailer);
ok(ctxt_sizes.cbBlockSize == 1,
"cbBlockSize should be 1 but is %lu\n",
ctxt_sizes.cbBlockSize);
}
else
trace("Unknown sec package %s\n", sec_pkg_name);
cleanupBuffers(&client);
cleanupBuffers(&server);