SSPI client to ldap Server - Error at last stage of n-way authentication check

SSPI client to ldap Server - Error at last stage of n-way authentication check

Secure Home | Search | About
 Microsoft Applications Security    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content add this group's latest topics to your Google content
Subject Author Date
SSPI client to ldap Server - Error at last stage of n-way authentication check amit 12-24-2005
Posted by amit on December 24, 2005, 1:15 am
If you were  Registered and logged in, you could reply and use other advanced thread options
Hi all,
I'm using Microsoft=AE Platform SDK 2003 and my client program is
using SSPI calls. I'm able to get 4 octet string token from TGT server
just before the final step of handshaking mechanism in SASL connection.

i=2Ee. my final step of three way handshaking is broken in the final step

where i'm calling EncryptMessage(..) [enquivant to gss_wrap( .. ) in
GSSAPI]. It is returning some garbage value (-122346..34) instead of
SEC_E_OK;


-------------------------------------
SAME WAY I'VE TRIED THE HANDSHAKING MECHANISM USING GSSAPI CALLS AND
.=2E...EVERYTHING IS WORKING FINE...
WHILE USING SSPI CALLS.....I'M GETTING PROBLEMS...............!!


Here is code snippet ----


--------- this step succeeded
err =3D pSecurityInterface->InitializeSecurityContext ( &hcredClient,
pClientCtxHandleIn,
TEXT("LDAP/ps2345.intranet.xyz....@INTRANET.XYZ.COM"),
grfRequiredCtxAttrsClient, 0, SECURITY_NATIVE_DREP, pClientInput, 0,
pClientCtxHandleOut, pClientOutput, &grfCtxAttrsClient,
&expiryClientCtx);


cbv.bv_len =3D pClientOutput->pBuffers[0].cbBuffer;
cbv.bv_val =3D (char*)pClientOutput->pBuffers[0].pvBuffer;


// successful call verified.....
retval =3D ldap_sasl_bind_s(ld, NULL, "GSSAPI", &cbv, NULL, NULL,
&sbv);
if ((retval =3D=3D LDAP_SASL_BIND_IN_PROGRESS || retval =3D=3D LDAP_SUCCE=
SS))



{
cbv.bv_len =3D 0;
cbv.bv_val =3D NULL;
if (sbv) {
ber_bvfree(sbv);
sbv =3D NULL;
}


//replying the challenge will NULL value
retval =3D ldap_sasl_bind_s(ld, NULL, "GSSAPI", &cbv, NULL,

NULL, &sbv);


if((retval =3D=3D LDAP_SASL_BIND_IN_PROGRESS || retval =3D=3D LDAP_SUCCES=
S))
{
inSecBufDesc.ulVersion =3D SECBUFFER_VERSION;
inSecBufDesc.cBuffers =3D 2;
inSecBufDesc.pBuffers =3D &inSecBuf[0];


inSecBuf[0].BufferType =3D SECBUFFER_STREAM;
inSecBuf[0].cbBuffer =3D sbv->bv_len;
inSecBuf[0].pvBuffer =3D sbv->bv_val;


inSecBuf[1].BufferType =3D SECBUFFER_DATA;
inSecBuf[1].cbBuffer =3D 0;
inSecBuf[1].pvBuffer =3D NULL;


ULONG mylongVal=3D0;


//Decrypting the Response.
err =3D pSecurityInterface->DecryptMessage(pClientCtxHandleIn,
&inSecBufDesc,
0,&mylongVal);


-------------- till here everything is successful....verified with
corresponding GSSPI call ...the (inSecBufDesc).pBuffers[1] contains the

4 byte octet string....Now according to rfc2222.txt, final step
required to wrap the data (EncryptMeassage call) in this case and use
final ldap_sasl_bind_s call


err =3D pSecurityInterface->QueryContextAttributes(
pClientCtxHandleIn, SECPKG_ATTR_SIZES, &sizes);


// password length is
passWd_Len =3D strlen("myuse...@INTRANET.XYZ.COM") + 4;
//setting the first byte of octet to 1
ptr =3D (unsigned char *)inSecBufDesc.pBuffers[1].pvBuffer;
maxsz =3D (ptr[1]<<16) | (ptr[2]<<8)| (ptr[3]);
ptr =3D (unsigned char *) malloc(passWd_Len);


ptr[0]=3D 1;
ptr[1]=3D maxsz>>16;
ptr[2]=3D maxsz>>8;
ptr[3]=3D maxsz;
sprintf((char *)&ptr[4], "%s", "myuse...@INTRANET.XYZ.COM");


---------------------------till here everything is ok....SAME AS DONE
WITH GSSAPI CALLS AND IS SUCCEEDED ...EVERYTHING IS FINE TILL HERE. NOW

THE JOB IS TO ENCRYPT AND SEND IT TO THE SERVER IN FINAL
CALL.-------------


--------------------Problem lies in next part of the code
---------------------


// Need three descriptors, two for the SSP and one to hold the
//application data.
inSecBufDescSecond.ulVersion =3D SECBUFFER_VERSION;
inSecBufDescSecond.cBuffers =3D 3;
inSecBufDescSecond.pBuffers =3D &inSecBufSec[0];


inSecBufSec[0].BufferType =3D SECBUFFER_TOKEN;
inSecBufSec[0].cbBuffer =3D sizes.cbSecurityTrailer;
inSecBufSec[0].pvBuffer =3D malloc(sizes.cbSecurityTrailer);


// This buffer holds the application data.
inSecBufSec[1].BufferType =3D SECBUFFER_DATA;
inSecBufSec[1].cbBuffer =3D passWd_Len;
inSecBufSec[1].pvBuffer =3D malloc(inSecBufSec[1].cbBuffer);
memcpy(inSecBufSec[1].pvBuffer, ptr, passWd_Len );
inSecBufSec[2].BufferType =3D SECBUFFER_PADDING;
inSecBufSec[2].cbBuffer =3D sizes.cbBlockSize;
inSecBufSec[2].pvBuffer =3D malloc(inSecBufSec[2].cbBuffer);


err =3D pSecurityInterface->EncryptMessage(pClientCtxHandleIn, ( 0 /
SECQOP_WRAP_NO_ENCRYPT ) ,&inSecBufDescSecond, 0);


----> if i keep second argument as SECQOP_WRAP_NO_ENCRYPT ....the call

returns SEC_E_OK , butinSecBufDescSecond.pBuffers[1] does not contains
the expected data. On the other hand keeping second argument
0=2E..returns error(-2146893054)


Let me know...where is the problem ??=20


Amit


Similar ThreadsPosted
SSPI client to ldap Server - Error at last stage of n-way authentication check December 24, 2005, 1:14 am
At which stage of the SSL handshake client/server 'decides' strenght of encryption ? January 11, 2006, 1:42 pm
HELP! Error /w Wireless Client Connecting to Win2003 Server /w IAS, CA November 12, 2005, 4:29 pm
Re: LDAP changePassword always returns error June 13, 2005, 10:55 am
Defender can't check for definition updates, error code 0x80240029 March 24, 2007, 12:12 pm
Impersonate a client after authentication December 5, 2006, 7:38 am
Error with Microsoft ForeFront Client Security May 28, 2008, 10:28 am
WLAN Security WPA EAP/TLS. Authentication Failed error March 6, 2008, 10:04 am
Antivirus on server or client? July 31, 2005, 6:50 am
Client can't reach SUS server December 13, 2005, 6:06 pm

The site map in XML format XML site map

Contact Us | Privacy Policy