Kai Blin : secur32: Implement QueryContextAttributes. Add tests.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 16 08:18:06 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 9d5e09d748c9558142f4b6ce3680f33adc65635b
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=9d5e09d748c9558142f4b6ce3680f33adc65635b

Author: Kai Blin <kai.blin at gmail.com>
Date:   Fri Jun 16 06:59:48 2006 +0000

secur32: Implement QueryContextAttributes. Add tests.

---

 dlls/secur32/ntlm.c       |   48 ++++++++++++++++++++++++++++++++-------------
 dlls/secur32/tests/main.c |   29 ++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/dlls/secur32/ntlm.c b/dlls/secur32/ntlm.c
index 3554f67..07beb39 100644
--- a/dlls/secur32/ntlm.c
+++ b/dlls/secur32/ntlm.c
@@ -31,7 +31,7 @@ #include "wine/debug.h"
 
 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_De
 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)
-    {
-        ret = SEC_E_UNSUPPORTED_FUNCTION;
-    }
-    else
+    if (!phContext)
+        return SEC_E_INVALID_HANDLE;
+
+    switch(ulAttribute)
     {
-        ret = SEC_E_INVALID_HANDLE;
+#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);
     }
-    return ret;
+
+    return SEC_E_UNSUPPORTED_FUNCTION;
 }
 
 /***********************************************************************
diff --git a/dlls/secur32/tests/main.c b/dlls/secur32/tests/main.c
index a673b73..0a00610 100644
--- a/dlls/secur32/tests/main.c
+++ b/dlls/secur32/tests/main.c
@@ -46,6 +46,7 @@ static SECURITY_STATUS (SEC_ENTRY * pAcc
                             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, UL
     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, UL
             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);
         




More information about the wine-cvs mailing list