libfreerdp-sspi: fix compilation on windows with UNICODE defined

This commit is contained in:
Marc-André Moreau 2012-03-24 15:47:16 -04:00
parent 679d5b68c6
commit e6ca39750a
6 changed files with 700 additions and 254 deletions

View File

@ -692,10 +692,10 @@ typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHan
typedef SECURITY_STATUS (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_A)(LPSTR pszPrincipal, LPSTR pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry);
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
typedef SECURITY_STATUS (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_W)(LPWSTR pszPrincipal, LPWSTR pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry);
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
#ifdef UNICODE
#define AcquireCredentialsHandle AcquireCredentialsHandleW
@ -809,38 +809,10 @@ typedef SECURITY_STATUS (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle ph
#define SET_CONTEXT_ATTRIBUTES_FN SET_CONTEXT_ATTRIBUTES_FN_A
#endif
struct _SecurityFunctionTable
{
uint32 dwVersion;
ENUMERATE_SECURITY_PACKAGES_FN EnumerateSecurityPackages;
QUERY_CREDENTIALS_ATTRIBUTES_FN QueryCredentialsAttributes;
ACQUIRE_CREDENTIALS_HANDLE_FN AcquireCredentialsHandle;
FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle;
void* Reserved2;
INITIALIZE_SECURITY_CONTEXT_FN InitializeSecurityContext;
ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext;
COMPLETE_AUTH_TOKEN_FN CompleteAuthToken;
DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext;
APPLY_CONTROL_TOKEN_FN ApplyControlToken;
QUERY_CONTEXT_ATTRIBUTES_FN QueryContextAttributes;
IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext;
REVERT_SECURITY_CONTEXT_FN RevertSecurityContext;
MAKE_SIGNATURE_FN MakeSignature;
VERIFY_SIGNATURE_FN VerifySignature;
FREE_CONTEXT_BUFFER_FN FreeContextBuffer;
QUERY_SECURITY_PACKAGE_INFO_FN QuerySecurityPackageInfo;
void* Reserved3;
void* Reserved4;
EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext;
IMPORT_SECURITY_CONTEXT_FN ImportSecurityContext;
ADD_CREDENTIALS_FN AddCredentials;
void* Reserved8;
QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken;
ENCRYPT_MESSAGE_FN EncryptMessage;
DECRYPT_MESSAGE_FN DecryptMessage;
SET_CONTEXT_ATTRIBUTES_FN SetContextAttributes;
};
typedef struct _SecurityFunctionTable SecurityFunctionTable;
#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION 1 /* Interface has all routines through DecryptMessage */
#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 2 /* Interface has all routines through SetContextAttributes */
#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3 3 /* Interface has all routines through SetCredentialsAttributes */
#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_4 4 /* Interface has all routines through ChangeAccountPassword */
struct _SecurityFunctionTableA
{
@ -922,59 +894,63 @@ typedef SecurityFunctionTableW* PSecurityFunctionTableW;
/* Package Management */
FREERDP_API SECURITY_STATUS EnumerateSecurityPackagesA(uint32* pcPackages, PSecPkgInfoA* ppPackageInfo);
FREERDP_API SECURITY_STATUS EnumerateSecurityPackagesW(uint32* pcPackages, PSecPkgInfoW* ppPackageInfo);
FREERDP_API SecurityFunctionTableA* InitSecurityInterfaceA(void);
FREERDP_API SecurityFunctionTableW* InitSecurityInterfaceW(void);
FREERDP_API SECURITY_STATUS QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo);
FREERDP_API SECURITY_STATUS QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo);
FREERDP_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(uint32* pcPackages, PSecPkgInfoA* ppPackageInfo);
FREERDP_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(uint32* pcPackages, PSecPkgInfoW* ppPackageInfo);
FREERDP_API SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceA(void);
FREERDP_API SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceW(void);
FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo);
FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo);
/* Credential Management */
FREERDP_API SECURITY_STATUS AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
FREERDP_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
FREERDP_API SECURITY_STATUS AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
FREERDP_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
FREERDP_API SECURITY_STATUS ExportSecurityContext(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken);
FREERDP_API SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential);
FREERDP_API SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken);
FREERDP_API SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle phCredential);
FREERDP_API SECURITY_STATUS ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS ImportSecurityContextW(SEC_WCHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
FREERDP_API SECURITY_STATUS QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
FREERDP_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
FREERDP_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
/* Context Management */
FREERDP_API SECURITY_STATUS AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
FREERDP_API SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsTimeStamp);
FREERDP_API SECURITY_STATUS ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput);
FREERDP_API SECURITY_STATUS CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken);
FREERDP_API SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS FreeContextBuffer(void* pvContextBuffer);
FREERDP_API SECURITY_STATUS ImpersonateSecurityContext(PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput);
FREERDP_API SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken);
FREERDP_API SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void* pvContextBuffer);
FREERDP_API SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS InitializeSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
FREERDP_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsExpiry);
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry);
FREERDP_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry);
FREERDP_API SECURITY_STATUS QueryContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer);
FREERDP_API SECURITY_STATUS QuerySecurityContextToken(PCtxtHandle phContext, void* phToken);
FREERDP_API SECURITY_STATUS SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer);
FREERDP_API SECURITY_STATUS RevertSecurityContext(PCtxtHandle phContext);
FREERDP_API SECURITY_STATUS SEC_ENTRY QueryContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer);
FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, void* phToken);
FREERDP_API SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer);
FREERDP_API SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext);
/* Message Support */
FREERDP_API SECURITY_STATUS DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
FREERDP_API SECURITY_STATUS EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
FREERDP_API SECURITY_STATUS MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
FREERDP_API SECURITY_STATUS VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
FREERDP_API SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
FREERDP_API SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
FREERDP_API SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
FREERDP_API SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
#endif

View File

@ -116,14 +116,19 @@ char* get_dns_queryname(char *host, char* protocol)
char* qname;
uint32 buflen;
buflen = 0;
if(protocol)
buflen = strlen(protocol);
buflen += strlen(host)+strlen(SERVICE)+1;
qname = (char*)xzalloc(buflen);
strcat(qname, SERVICE);
if(protocol)
strcat(qname, protocol);
strcat(qname, host);
return qname;
}
@ -259,7 +264,7 @@ int krb_tcp_send(KRB_CONTEXT* krb_ctx, uint8* data, uint32 length)
return freerdp_tcp_write(krb_ctx->ksockfd, data, length);
}
KRB_CONTEXT* krb_ContextNew()
KRB_CONTEXT* kerberos_ContextNew()
{
KRB_CONTEXT* context;
@ -275,7 +280,41 @@ KRB_CONTEXT* krb_ContextNew()
return context;
}
SECURITY_STATUS SEC_ENTRY krb_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
void kerberos_ContextFree(KRB_CONTEXT* krb_ctx)
{
if (krb_ctx != NULL)
{
xfree(krb_ctx->krbhost);
xfree(krb_ctx->cname);
xfree(krb_ctx->realm);
freerdp_blob_free(&(krb_ctx->passwd));
if(krb_ctx->askey != NULL)
{
freerdp_blob_free(&(krb_ctx->askey->skey));
xfree(krb_ctx->askey);
}
if(krb_ctx->tgskey != NULL)
{
freerdp_blob_free(&(krb_ctx->tgskey->skey));
xfree(krb_ctx->tgskey);
}
krb_free_ticket(&(krb_ctx->asticket));
krb_free_ticket(&(krb_ctx->tgsticket));
krb_ctx->state = KRB_STATE_FINAL;
}
}
SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry)
{
@ -298,7 +337,7 @@ SECURITY_STATUS SEC_ENTRY krb_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal,
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY krb_FreeCredentialsHandle(PCredHandle phCredential)
SECURITY_STATUS SEC_ENTRY kerberos_FreeCredentialsHandle(PCredHandle phCredential)
{
CREDENTIALS* credentials;
@ -315,7 +354,12 @@ SECURITY_STATUS SEC_ENTRY krb_FreeCredentialsHandle(PCredHandle phCredential)
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY krb_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
{
@ -324,8 +368,8 @@ SECURITY_STATUS SEC_ENTRY krb_QueryCredentialsAttributesA(PCredHandle phCredenti
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
credential_names->sUserName = xstrdup((char*) credentials->identity.User);
//if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
// credential_names->sUserName = xstrdup((char*) credentials->identity.User);
return SEC_E_OK;
}
@ -381,10 +425,18 @@ void krb_SetContextIdentity(KRB_CONTEXT* context, SEC_WINNT_AUTH_IDENTITY* ident
}
}
SECURITY_STATUS SEC_ENTRY krb_InitializeSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsExpiry)
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
KRB_CONTEXT* krb_ctx;
//SECURITY_STATUS status;
@ -405,7 +457,7 @@ SECURITY_STATUS SEC_ENTRY krb_InitializeSecurityContext(PCredHandle phCredential
switch(krb_ctx->state)
{
case KRB_PACKET_ERROR:
krb_ContextFree(krb_ctx);
kerberos_ContextFree(krb_ctx);
return SEC_E_INVALID_HANDLE;
break;
case KRB_STATE_INITIAL:
@ -442,19 +494,21 @@ PCtxtHandle krbctx_client_init(rdpSettings* settings, SEC_WINNT_AUTH_IDENTITY* i
uint32 pfContextAttr;
TimeStamp expiration;
if(tcp_is_ipaddr(settings->hostname))
if (tcp_is_ipaddr(settings->hostname))
return NULL;
kdclist = krb_locate_kdc(settings);
/* start the state machine with initialized to zero */
krb_ctx = krb_ContextNew();
krb_ctx = kerberos_ContextNew();
for (entry = kdclist;entry != NULL; entry = entry->next)
{
if(!krb_tcp_connect(krb_ctx, entry))
break;
}
if(entry == NULL)
if (entry == NULL)
{
xfree(krb_ctx);
return NULL;
@ -464,19 +518,16 @@ PCtxtHandle krbctx_client_init(rdpSettings* settings, SEC_WINNT_AUTH_IDENTITY* i
krb_ctx->realm = xstrtoup(settings->kerberos_realm);
krb_ctx->cname = xstrdup((char*)krb_ctx->identity.User);
krb_ctx->settings = settings;
krb_ctx->passwd.data = freerdp_uniconv_out(krb_ctx->uniconv, (char*)krb_ctx->identity.Password, (size_t*) &(krb_ctx->passwd.length));
krb_ctx->passwd.data = freerdp_uniconv_out(krb_ctx->uniconv, (char*) krb_ctx->identity.Password, (size_t*) &(krb_ctx->passwd.length));
fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT |
ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE;
sspi_SecureHandleSetLowerPointer(&krb_ctx->context, krb_ctx);
sspi_SecureHandleSetUpperPointer(&krb_ctx->context, (void*)KRB_PACKAGE_NAME);
sspi_SecureHandleSetUpperPointer(&krb_ctx->context, (void*) KRB_PACKAGE_NAME);
status = krb_InitializeSecurityContext(NULL,
&krb_ctx->context ,
NULL, fContextReq, 0, SECURITY_NATIVE_DREP,
NULL,
0, &krb_ctx->context, NULL, &pfContextAttr, &expiration);
status = kerberos_InitializeSecurityContextA(NULL, &krb_ctx->context, NULL,
fContextReq, 0, SECURITY_NATIVE_DREP, NULL, 0, &krb_ctx->context, NULL, &pfContextAttr, &expiration);
if(status == SEC_E_INVALID_HANDLE)
{
@ -1120,31 +1171,12 @@ void krb_free_krb_error(KrbERROR* krb_err)
}
}
void krb_ContextFree(KRB_CONTEXT* krb_ctx)
SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
if(krb_ctx != NULL)
{
xfree(krb_ctx->krbhost);
xfree(krb_ctx->cname);
xfree(krb_ctx->realm);
freerdp_blob_free(&(krb_ctx->passwd));
if(krb_ctx->askey != NULL)
{
freerdp_blob_free(&(krb_ctx->askey->skey));
xfree(krb_ctx->askey);
}
if(krb_ctx->tgskey != NULL)
{
freerdp_blob_free(&(krb_ctx->tgskey->skey));
xfree(krb_ctx->tgskey);
}
krb_free_ticket(&(krb_ctx->asticket));
krb_free_ticket(&(krb_ctx->tgsticket));
krb_ctx->state = KRB_STATE_FINAL;
}
return SEC_E_OK;
}
SECURITY_STATUS krb_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
if (!phContext)
return SEC_E_INVALID_HANDLE;
@ -1167,27 +1199,27 @@ SECURITY_STATUS krb_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttr
return SEC_E_UNSUPPORTED_FUNCTION;
}
SECURITY_STATUS SEC_ENTRY krb_EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY krb_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY krb_MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY krb_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
{
return SEC_E_OK;
}
const SecPkgInfo KRB_SecPkgInfo =
const SecPkgInfoA KERBEROS_SecPkgInfoA =
{
0x000F3BBF, /* fCapabilities */
1, /* wVersion */
@ -1197,24 +1229,34 @@ const SecPkgInfo KRB_SecPkgInfo =
"Microsoft Kerberos V1.0" /* Comment */
};
const SecurityFunctionTable KRB_SecurityFunctionTable =
const SecPkgInfoW KERBEROS_SecPkgInfoW =
{
0x000F3BBF, /* fCapabilities */
1, /* wVersion */
0x0010, /* wRPCID */
0x00002EE0, /* cbMaxToken */
L"Kerberos", /* Name */
L"Microsoft Kerberos V1.0" /* Comment */
};
const SecurityFunctionTableA KERBEROS_SecurityFunctionTableA =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
krb_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
krb_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
krb_FreeCredentialsHandle, /* FreeCredentialsHandle */
kerberos_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
kerberos_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
krb_InitializeSecurityContext, /* InitializeSecurityContext */
kerberos_InitializeSecurityContextA, /* InitializeSecurityContext */
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
krb_QueryContextAttributesA, /* QueryContextAttributes */
kerberos_QueryContextAttributesA, /* QueryContextAttributes */
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
krb_MakeSignature, /* MakeSignature */
krb_VerifySignature, /* VerifySignature */
kerberos_MakeSignature, /* MakeSignature */
kerberos_VerifySignature, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
@ -1224,7 +1266,39 @@ const SecurityFunctionTable KRB_SecurityFunctionTable =
NULL, /* AddCredentials */
NULL, /* Reserved8 */
NULL, /* QuerySecurityContextToken */
krb_EncryptMessage, /* EncryptMessage */
krb_DecryptMessage, /* DecryptMessage */
kerberos_EncryptMessage, /* EncryptMessage */
kerberos_DecryptMessage, /* DecryptMessage */
NULL, /* SetContextAttributes */
};
const SecurityFunctionTableW KERBEROS_SecurityFunctionTableW =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
kerberos_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
kerberos_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
kerberos_InitializeSecurityContextW, /* InitializeSecurityContext */
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
kerberos_QueryContextAttributesW, /* QueryContextAttributes */
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
kerberos_MakeSignature, /* MakeSignature */
kerberos_VerifySignature, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
NULL, /* ExportSecurityContext */
NULL, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
NULL, /* QuerySecurityContextToken */
kerberos_EncryptMessage, /* EncryptMessage */
kerberos_DecryptMessage, /* DecryptMessage */
NULL, /* SetContextAttributes */
};

View File

@ -138,7 +138,14 @@ void ntlm_ContextFree(NTLM_CONTEXT* context)
xfree(context);
}
SECURITY_STATUS ntlm_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(LPWSTR pszPrincipal, LPWSTR pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(LPSTR pszPrincipal, LPSTR pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
@ -173,7 +180,7 @@ SECURITY_STATUS ntlm_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR*
return SEC_E_OK;
}
SECURITY_STATUS ntlm_FreeCredentialsHandle(PCredHandle phCredential)
SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle phCredential)
{
CREDENTIALS* credentials;
@ -190,6 +197,24 @@ SECURITY_STATUS ntlm_FreeCredentialsHandle(PCredHandle phCredential)
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
{
CREDENTIALS* credentials;
SecPkgCredentials_Names* credential_names = (SecPkgCredentials_Names*) pBuffer;
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
//if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
// credential_names->sUserName = xstrdup((char*) credentials->identity.User);
return SEC_E_OK;
}
return SEC_E_UNSUPPORTED_FUNCTION;
}
SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
@ -199,8 +224,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredent
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
credential_names->sUserName = xstrdup((char*) credentials->identity.User);
//if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
// credential_names->sUserName = xstrdup((char*) credentials->identity.User);
return SEC_E_OK;
}
@ -312,8 +337,16 @@ SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext(PCtxtHandle phContext)
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
@ -416,15 +449,22 @@ SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContext)
NTLM_CONTEXT* context;
context = sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
return SEC_E_INVALID_HANDLE;
ntlm_ContextFree(context);
return SEC_E_OK;
}
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa379337/ */
SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
if (!phContext)
@ -606,7 +646,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext, PSecBuffer
return SEC_E_OK;
}
const SecPkgInfo NTLM_SecPkgInfo =
const SecPkgInfoA NTLM_SecPkgInfoA =
{
0x00082B37, /* fCapabilities */
1, /* wVersion */
@ -616,7 +656,17 @@ const SecPkgInfo NTLM_SecPkgInfo =
"NTLM Security Package" /* Comment */
};
const SecurityFunctionTable NTLM_SecurityFunctionTable =
const SecPkgInfoW NTLM_SecPkgInfoW =
{
0x00082B37, /* fCapabilities */
1, /* wVersion */
0x000A, /* wRPCID */
0x00000B48, /* cbMaxToken */
L"NTLM", /* Name */
L"NTLM Security Package" /* Comment */
};
const SecurityFunctionTableA NTLM_SecurityFunctionTableA =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
@ -647,3 +697,35 @@ const SecurityFunctionTable NTLM_SecurityFunctionTable =
ntlm_DecryptMessage, /* DecryptMessage */
NULL, /* SetContextAttributes */
};
const SecurityFunctionTableW NTLM_SecurityFunctionTableW =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
ntlm_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
ntlm_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
ntlm_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
ntlm_InitializeSecurityContextW, /* InitializeSecurityContext */
ntlm_AcceptSecurityContext, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
ntlm_DeleteSecurityContext, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
ntlm_QueryContextAttributesW, /* QueryContextAttributes */
ntlm_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
ntlm_RevertSecurityContext, /* RevertSecurityContext */
ntlm_MakeSignature, /* MakeSignature */
ntlm_VerifySignature, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
NULL, /* ExportSecurityContext */
NULL, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
NULL, /* QuerySecurityContextToken */
ntlm_EncryptMessage, /* EncryptMessage */
ntlm_DecryptMessage, /* DecryptMessage */
NULL, /* SetContextAttributes */
};

View File

@ -26,7 +26,7 @@
char* NEGOTIATE_PACKAGE_NAME = "Negotiate";
const SecPkgInfo NEGOTIATE_SecPkgInfo =
const SecPkgInfoA NEGOTIATE_SecPkgInfoA =
{
0x00083BB3, /* fCapabilities */
1, /* wVersion */
@ -36,6 +36,16 @@ const SecPkgInfo NEGOTIATE_SecPkgInfo =
"Microsoft Package Negotiator" /* Comment */
};
const SecPkgInfoW NEGOTIATE_SecPkgInfoW =
{
0x00083BB3, /* fCapabilities */
1, /* wVersion */
0x0009, /* wRPCID */
0x00002FE0, /* cbMaxToken */
L"Negotiate", /* Name */
L"Microsoft Package Negotiator" /* Comment */
};
void negotiate_SetContextIdentity(NEGOTIATE_CONTEXT* context, SEC_WINNT_AUTH_IDENTITY* identity)
{
size_t size;
@ -81,10 +91,18 @@ void negotiate_SetContextIdentity(NEGOTIATE_CONTEXT* context, SEC_WINNT_AUTH_IDE
}
}
SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsExpiry)
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
NEGOTIATE_CONTEXT* context;
//SECURITY_STATUS status;
@ -171,9 +189,16 @@ SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributes(PCtxtHandle phContext
return SEC_E_UNSUPPORTED_FUNCTION;
}
SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandle(char* pszPrincipal, char* pszPackage,
SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry)
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
CREDENTIALS* credentials;
SEC_WINNT_AUTH_IDENTITY* identity;
@ -194,6 +219,11 @@ SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandle(char* pszPrincipal,
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
@ -203,8 +233,8 @@ SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(PCredHandle phCr
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
credential_names->sUserName = xstrdup((char*) credentials->identity.User);
//if (credentials->identity.Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
// credential_names->sUserName = xstrdup((char*) credentials->identity.User);
return SEC_E_OK;
}
@ -244,20 +274,52 @@ SECURITY_STATUS SEC_ENTRY negotiate_MakeSignature(PCtxtHandle phContext, uint32
return SEC_E_OK;
}
SECURITY_STATUS negotiate_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
{
return SEC_E_OK;
}
const SecurityFunctionTable NEGOTIATE_SecurityFunctionTable =
const SecurityFunctionTableA NEGOTIATE_SecurityFunctionTableA =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
negotiate_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
negotiate_AcquireCredentialsHandle, /* AcquireCredentialsHandle */
negotiate_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
negotiate_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
negotiate_InitializeSecurityContext, /* InitializeSecurityContext */
negotiate_InitializeSecurityContextA, /* InitializeSecurityContext */
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
negotiate_QueryContextAttributes, /* QueryContextAttributes */
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
negotiate_MakeSignature, /* MakeSignature */
negotiate_VerifySignature, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
NULL, /* ExportSecurityContext */
NULL, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
NULL, /* QuerySecurityContextToken */
negotiate_EncryptMessage, /* EncryptMessage */
negotiate_DecryptMessage, /* DecryptMessage */
NULL, /* SetContextAttributes */
};
const SecurityFunctionTableW NEGOTIATE_SecurityFunctionTableW =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
negotiate_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
negotiate_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
negotiate_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
negotiate_InitializeSecurityContextW, /* InitializeSecurityContext */
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */

View File

@ -152,7 +152,11 @@ int credssp_ntlm_server_init(rdpCredssp* credssp)
return 1;
}
#ifdef UNICODE
#define NTLM_PACKAGE_NAME L"NTLM"
#else
#define NTLM_PACKAGE_NAME "NTLM"
#endif
int credssp_client_authenticate(rdpCredssp* credssp)
{
@ -1028,7 +1032,7 @@ void credssp_free(rdpCredssp* credssp)
/* SSPI */
const SecurityFunctionTable CREDSSP_SecurityFunctionTable =
const SecurityFunctionTableA CREDSSP_SecurityFunctionTableA =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
@ -1060,7 +1064,39 @@ const SecurityFunctionTable CREDSSP_SecurityFunctionTable =
NULL /* SetContextAttributes */
};
const SecPkgInfo CREDSSP_SecPkgInfo =
const SecurityFunctionTableW CREDSSP_SecurityFunctionTableW =
{
1, /* dwVersion */
NULL, /* EnumerateSecurityPackages */
NULL, /* QueryCredentialsAttributes */
NULL, /* AcquireCredentialsHandle */
NULL, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
NULL, /* InitializeSecurityContext */
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
NULL, /* QueryContextAttributes */
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
NULL, /* MakeSignature */
NULL, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
NULL, /* ExportSecurityContext */
NULL, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
NULL, /* QuerySecurityContextToken */
NULL, /* EncryptMessage */
NULL, /* DecryptMessage */
NULL /* SetContextAttributes */
};
const SecPkgInfoA CREDSSP_SecPkgInfoA =
{
0x000110733, /* fCapabilities */
1, /* wVersion */
@ -1069,3 +1105,13 @@ const SecPkgInfo CREDSSP_SecPkgInfo =
"CREDSSP", /* Name */
"Microsoft CredSSP Security Provider" /* Comment */
};
const SecPkgInfoW CREDSSP_SecPkgInfoW =
{
0x000110733, /* fCapabilities */
1, /* wVersion */
0xFFFF, /* wRPCID */
0x000090A8, /* cbMaxToken */
L"CREDSSP", /* Name */
L"Microsoft CredSSP Security Provider" /* Comment */
};

View File

@ -27,31 +27,55 @@
#ifdef FREERDP_SSPI
extern const SecPkgInfo NTLM_SecPkgInfo;
extern const SecPkgInfo CREDSSP_SecPkgInfo;
extern const SecPkgInfoA NTLM_SecPkgInfoA;
extern const SecPkgInfoW NTLM_SecPkgInfoW;
extern const SecPkgInfoA CREDSSP_SecPkgInfoA;
extern const SecPkgInfoW CREDSSP_SecPkgInfoW;
extern const SecurityFunctionTable NTLM_SecurityFunctionTable;
extern const SecurityFunctionTable CREDSSP_SecurityFunctionTable;
extern const SecurityFunctionTableA NTLM_SecurityFunctionTableA;
extern const SecurityFunctionTableW NTLM_SecurityFunctionTableW;
extern const SecurityFunctionTableA CREDSSP_SecurityFunctionTableA;
extern const SecurityFunctionTableW CREDSSP_SecurityFunctionTableW;
const SecPkgInfo* SecPkgInfo_LIST[] =
const SecPkgInfoA* SecPkgInfoA_LIST[] =
{
&NTLM_SecPkgInfo,
&CREDSSP_SecPkgInfo
&NTLM_SecPkgInfoA,
&CREDSSP_SecPkgInfoA
};
const SecurityFunctionTable SSPI_SecurityFunctionTable;
struct _SecurityFunctionTable_NAME
const SecPkgInfoW* SecPkgInfoW_LIST[] =
{
char* Name;
const SecurityFunctionTable* SecurityFunctionTable;
&NTLM_SecPkgInfoW,
&CREDSSP_SecPkgInfoW
};
typedef struct _SecurityFunctionTable_NAME SecurityFunctionTable_NAME;
const SecurityFunctionTable_NAME SecurityFunctionTable_NAME_LIST[] =
SecurityFunctionTableA SSPI_SecurityFunctionTableA;
SecurityFunctionTableW SSPI_SecurityFunctionTableW;
struct _SecurityFunctionTableA_NAME
{
{ "NTLM", &NTLM_SecurityFunctionTable },
{ "CREDSSP", &CREDSSP_SecurityFunctionTable }
SEC_CHAR* Name;
const SecurityFunctionTableA* SecurityFunctionTable;
};
typedef struct _SecurityFunctionTableA_NAME SecurityFunctionTableA_NAME;
struct _SecurityFunctionTableW_NAME
{
SEC_WCHAR* Name;
const SecurityFunctionTableW* SecurityFunctionTable;
};
typedef struct _SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME;
const SecurityFunctionTableA_NAME SecurityFunctionTableA_NAME_LIST[] =
{
{ "NTLM", &NTLM_SecurityFunctionTableA },
{ "CREDSSP", &CREDSSP_SecurityFunctionTableA }
};
const SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME_LIST[] =
{
{ L"NTLM", &NTLM_SecurityFunctionTableW },
{ L"CREDSSP", &CREDSSP_SecurityFunctionTableW }
};
#endif
@ -252,18 +276,36 @@ void sspi_GlobalFinish()
#ifndef NATIVE_SSPI
SecurityFunctionTable* sspi_GetSecurityFunctionTableByName(const char* Name)
SecurityFunctionTableA* sspi_GetSecurityFunctionTableByNameA(const SEC_CHAR* Name)
{
int index;
uint32 cPackages;
cPackages = ARRAY_SIZE(SecPkgInfo_LIST);
cPackages = ARRAY_SIZE(SecPkgInfoA_LIST);
for (index = 0; index < (int) cPackages; index++)
{
if (strcmp(Name, SecurityFunctionTable_NAME_LIST[index].Name) == 0)
if (strcmp(Name, SecurityFunctionTableA_NAME_LIST[index].Name) == 0)
{
return (SecurityFunctionTable*) SecurityFunctionTable_NAME_LIST[index].SecurityFunctionTable;
return (SecurityFunctionTableA*) SecurityFunctionTableA_NAME_LIST[index].SecurityFunctionTable;
}
}
return NULL;
}
SecurityFunctionTableW* sspi_GetSecurityFunctionTableByNameW(const SEC_WCHAR* Name)
{
int index;
uint32 cPackages;
cPackages = ARRAY_SIZE(SecPkgInfoW_LIST);
for (index = 0; index < (int) cPackages; index++)
{
if (wcscmp(Name, SecurityFunctionTableW_NAME_LIST[index].Name) == 0)
{
return (SecurityFunctionTableW*) SecurityFunctionTableW_NAME_LIST[index].SecurityFunctionTable;
}
}
@ -306,26 +348,54 @@ void sspi_ContextBufferFree(void* contextBuffer)
/* Package Management */
SECURITY_STATUS EnumerateSecurityPackages(uint32* pcPackages, SecPkgInfo** ppPackageInfo)
SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(uint32* pcPackages, PSecPkgInfoW* ppPackageInfo)
{
int index;
size_t size;
uint32 cPackages;
SecPkgInfo* pPackageInfo;
SecPkgInfoW* pPackageInfo;
cPackages = ARRAY_SIZE(SecPkgInfo_LIST);
size = sizeof(SecPkgInfo) * cPackages;
cPackages = ARRAY_SIZE(SecPkgInfoW_LIST);
size = sizeof(SecPkgInfoW) * cPackages;
pPackageInfo = (SecPkgInfo*) sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
pPackageInfo = (SecPkgInfoW*) sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
for (index = 0; index < (int) cPackages; index++)
{
pPackageInfo[index].fCapabilities = SecPkgInfo_LIST[index]->fCapabilities;
pPackageInfo[index].wVersion = SecPkgInfo_LIST[index]->wVersion;
pPackageInfo[index].wRPCID = SecPkgInfo_LIST[index]->wRPCID;
pPackageInfo[index].cbMaxToken = SecPkgInfo_LIST[index]->cbMaxToken;
pPackageInfo[index].Name = xstrdup(SecPkgInfo_LIST[index]->Name);
pPackageInfo[index].Comment = xstrdup(SecPkgInfo_LIST[index]->Comment);
pPackageInfo[index].fCapabilities = SecPkgInfoW_LIST[index]->fCapabilities;
pPackageInfo[index].wVersion = SecPkgInfoW_LIST[index]->wVersion;
pPackageInfo[index].wRPCID = SecPkgInfoW_LIST[index]->wRPCID;
pPackageInfo[index].cbMaxToken = SecPkgInfoW_LIST[index]->cbMaxToken;
pPackageInfo[index].Name = _wcsdup(SecPkgInfoW_LIST[index]->Name);
pPackageInfo[index].Comment = _wcsdup(SecPkgInfoW_LIST[index]->Comment);
}
*(pcPackages) = cPackages;
*(ppPackageInfo) = pPackageInfo;
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(uint32* pcPackages, PSecPkgInfoA* ppPackageInfo)
{
int index;
size_t size;
uint32 cPackages;
SecPkgInfoA* pPackageInfo;
cPackages = ARRAY_SIZE(SecPkgInfoA_LIST);
size = sizeof(SecPkgInfoA) * cPackages;
pPackageInfo = (SecPkgInfoA*) sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
for (index = 0; index < (int) cPackages; index++)
{
pPackageInfo[index].fCapabilities = SecPkgInfoA_LIST[index]->fCapabilities;
pPackageInfo[index].wVersion = SecPkgInfoA_LIST[index]->wVersion;
pPackageInfo[index].wRPCID = SecPkgInfoA_LIST[index]->wRPCID;
pPackageInfo[index].cbMaxToken = SecPkgInfoA_LIST[index]->cbMaxToken;
pPackageInfo[index].Name = xstrdup(SecPkgInfoA_LIST[index]->Name);
pPackageInfo[index].Comment = xstrdup(SecPkgInfoA_LIST[index]->Comment);
}
*(pcPackages) = cPackages;
@ -338,9 +408,9 @@ void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer)
{
int index;
uint32 cPackages;
SecPkgInfo* pPackageInfo = (SecPkgInfo*) contextBuffer;
SecPkgInfoA* pPackageInfo = (SecPkgInfoA*) contextBuffer;
cPackages = ARRAY_SIZE(SecPkgInfo_LIST);
cPackages = ARRAY_SIZE(SecPkgInfoA_LIST);
for (index = 0; index < (int) cPackages; index++)
{
@ -354,36 +424,72 @@ void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer)
xfree(pPackageInfo);
}
SecurityFunctionTable* InitSecurityInterface(void)
SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceW(void)
{
SecurityFunctionTable* table;
table = xnew(SecurityFunctionTable);
memcpy((void*) table, (void*) &SSPI_SecurityFunctionTable, sizeof(SecurityFunctionTable));
return table;
return &SSPI_SecurityFunctionTableW;
}
SECURITY_STATUS QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo)
SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceA(void)
{
return &SSPI_SecurityFunctionTableA;
}
SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo)
{
int index;
size_t size;
uint32 cPackages;
SecPkgInfo* pPackageInfo;
SecPkgInfoW* pPackageInfo;
cPackages = ARRAY_SIZE(SecPkgInfo_LIST);
cPackages = ARRAY_SIZE(SecPkgInfoW_LIST);
for (index = 0; index < (int) cPackages; index++)
{
if (strcmp(pszPackageName, SecPkgInfo_LIST[index]->Name) == 0)
if (wcscmp(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0)
{
size = sizeof(SecPkgInfo);
pPackageInfo = (SecPkgInfo*) sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
size = sizeof(SecPkgInfoW);
pPackageInfo = (SecPkgInfoW*) sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
pPackageInfo->fCapabilities = SecPkgInfo_LIST[index]->fCapabilities;
pPackageInfo->wVersion = SecPkgInfo_LIST[index]->wVersion;
pPackageInfo->wRPCID = SecPkgInfo_LIST[index]->wRPCID;
pPackageInfo->cbMaxToken = SecPkgInfo_LIST[index]->cbMaxToken;
pPackageInfo->Name = xstrdup(SecPkgInfo_LIST[index]->Name);
pPackageInfo->Comment = xstrdup(SecPkgInfo_LIST[index]->Comment);
pPackageInfo->fCapabilities = SecPkgInfoW_LIST[index]->fCapabilities;
pPackageInfo->wVersion = SecPkgInfoW_LIST[index]->wVersion;
pPackageInfo->wRPCID = SecPkgInfoW_LIST[index]->wRPCID;
pPackageInfo->cbMaxToken = SecPkgInfoW_LIST[index]->cbMaxToken;
pPackageInfo->Name = _wcsdup(SecPkgInfoW_LIST[index]->Name);
pPackageInfo->Comment = _wcsdup(SecPkgInfoW_LIST[index]->Comment);
*(ppPackageInfo) = pPackageInfo;
return SEC_E_OK;
}
}
*(ppPackageInfo) = NULL;
return SEC_E_SECPKG_NOT_FOUND;
}
SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo)
{
int index;
size_t size;
uint32 cPackages;
SecPkgInfoA* pPackageInfo;
cPackages = ARRAY_SIZE(SecPkgInfoA_LIST);
for (index = 0; index < (int) cPackages; index++)
{
if (strcmp(pszPackageName, SecPkgInfoA_LIST[index]->Name) == 0)
{
size = sizeof(SecPkgInfoA);
pPackageInfo = (SecPkgInfoA*) sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
pPackageInfo->fCapabilities = SecPkgInfoA_LIST[index]->fCapabilities;
pPackageInfo->wVersion = SecPkgInfoA_LIST[index]->wVersion;
pPackageInfo->wRPCID = SecPkgInfoA_LIST[index]->wRPCID;
pPackageInfo->cbMaxToken = SecPkgInfoA_LIST[index]->cbMaxToken;
pPackageInfo->Name = xstrdup(SecPkgInfoA_LIST[index]->Name);
pPackageInfo->Comment = xstrdup(SecPkgInfoA_LIST[index]->Comment);
*(ppPackageInfo) = pPackageInfo;
@ -411,42 +517,49 @@ void FreeContextBuffer_QuerySecurityPackageInfo(void* contextBuffer)
/* Credential Management */
SECURITY_STATUS AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status;
SecurityFunctionTable* table = sspi_GetSecurityFunctionTableByName(pszPackage);
SecurityFunctionTableA* table = sspi_GetSecurityFunctionTableByNameA(pszPackage);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->AcquireCredentialsHandle == NULL)
if (table->AcquireCredentialsHandleA == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->AcquireCredentialsHandle(pszPrincipal, pszPackage, fCredentialUse,
status = table->AcquireCredentialsHandleA(pszPrincipal, pszPackage, fCredentialUse,
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
return status;
}
SECURITY_STATUS ExportSecurityContextA(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken)
SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken)
{
return SEC_E_OK;
}
SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential)
SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle phCredential)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -459,51 +572,80 @@ SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential)
return status;
}
SECURITY_STATUS ImportSecurityContextA(char* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext)
SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext)
{
return SEC_E_OK;
}
SECURITY_STATUS QueryCredentialsAttributes(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
SEC_WCHAR* Name;
SECURITY_STATUS status;
SecurityFunctionTableW* table;
Name = (SEC_WCHAR*) sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByNameW(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->QueryCredentialsAttributesW == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
return status;
}
SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->QueryCredentialsAttributes == NULL)
if (table->QueryCredentialsAttributesA == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->QueryCredentialsAttributes(phCredential, ulAttribute, pBuffer);
status = table->QueryCredentialsAttributesA(phCredential, ulAttribute, pBuffer);
return status;
}
/* Context Management */
SECURITY_STATUS AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsTimeStamp)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -517,28 +659,28 @@ SECURITY_STATUS AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phCo
return status;
}
SECURITY_STATUS ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
{
return SEC_E_OK;
}
SECURITY_STATUS CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
{
return SEC_E_OK;
}
SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -551,7 +693,7 @@ SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext)
return status;
}
SECURITY_STATUS FreeContextBuffer(void* pvContextBuffer)
SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void* pvContextBuffer)
{
if (!pvContextBuffer)
return SEC_E_INVALID_HANDLE;
@ -561,93 +703,125 @@ SECURITY_STATUS FreeContextBuffer(void* pvContextBuffer)
return SEC_E_OK;
}
SECURITY_STATUS ImpersonateSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext)
{
return SEC_E_OK;
}
SECURITY_STATUS InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
return SEC_E_OK;
}
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
{
SEC_CHAR* Name;
SECURITY_STATUS status;
SecurityFunctionTableA* table;
Name = (SEC_CHAR*) sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->InitializeSecurityContext == NULL)
if (table->InitializeSecurityContextA == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->InitializeSecurityContext(phCredential, phContext,
status = table->InitializeSecurityContextA(phCredential, phContext,
pszTargetName, fContextReq, Reserved1, TargetDataRep,
pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
return status;
}
SECURITY_STATUS QueryContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
char* Name;
SEC_WCHAR* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableW* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
Name = (SEC_WCHAR*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameW(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->QueryContextAttributes == NULL)
if (table->QueryContextAttributesW == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->QueryContextAttributes(phContext, ulAttribute, pBuffer);
status = table->QueryContextAttributesW(phContext, ulAttribute, pBuffer);
return status;
}
SECURITY_STATUS QuerySecurityContextToken(PCtxtHandle phContext, void* phToken)
SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
{
SEC_CHAR* Name;
SECURITY_STATUS status;
SecurityFunctionTableA* table;
Name = (SEC_CHAR*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->QueryContextAttributesA == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->QueryContextAttributesA(phContext, ulAttribute, pBuffer);
return status;
}
SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, void* phToken)
{
return SEC_E_OK;
}
SECURITY_STATUS SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer)
SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer)
{
return SEC_E_OK;
}
SECURITY_STATUS RevertSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext)
{
return SEC_E_OK;
}
/* Message Support */
SECURITY_STATUS DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -660,18 +834,18 @@ SECURITY_STATUS DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, u
return status;
}
SECURITY_STATUS EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -684,18 +858,18 @@ SECURITY_STATUS EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDes
return status;
}
SECURITY_STATUS MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -708,18 +882,18 @@ SECURITY_STATUS MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc
return status;
}
SECURITY_STATUS VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
{
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
SecurityFunctionTableA* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
table = sspi_GetSecurityFunctionTableByNameA(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
@ -732,12 +906,12 @@ SECURITY_STATUS VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage,
return status;
}
const SecurityFunctionTable SSPI_SecurityFunctionTable =
SecurityFunctionTableA SSPI_SecurityFunctionTableA =
{
1, /* dwVersion */
EnumerateSecurityPackages, /* EnumerateSecurityPackages */
QueryCredentialsAttributes, /* QueryCredentialsAttributes */
AcquireCredentialsHandle, /* AcquireCredentialsHandle */
EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
InitializeSecurityContextA, /* InitializeSecurityContext */
@ -754,8 +928,40 @@ const SecurityFunctionTable SSPI_SecurityFunctionTable =
QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
ExportSecurityContextA, /* ExportSecurityContext */
ImportSecurityContext, /* ImportSecurityContext */
ExportSecurityContext, /* ExportSecurityContext */
ImportSecurityContextA, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
QuerySecurityContextToken, /* QuerySecurityContextToken */
EncryptMessage, /* EncryptMessage */
DecryptMessage, /* DecryptMessage */
SetContextAttributes, /* SetContextAttributes */
};
SecurityFunctionTableW SSPI_SecurityFunctionTableW =
{
1, /* dwVersion */
EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
InitializeSecurityContextW, /* InitializeSecurityContext */
AcceptSecurityContext, /* AcceptSecurityContext */
CompleteAuthToken, /* CompleteAuthToken */
DeleteSecurityContext, /* DeleteSecurityContext */
ApplyControlToken, /* ApplyControlToken */
QueryContextAttributes, /* QueryContextAttributes */
ImpersonateSecurityContext, /* ImpersonateSecurityContext */
RevertSecurityContext, /* RevertSecurityContext */
MakeSignature, /* MakeSignature */
VerifySignature, /* VerifySignature */
FreeContextBuffer, /* FreeContextBuffer */
QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
ExportSecurityContext, /* ExportSecurityContext */
ImportSecurityContextW, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
QuerySecurityContextToken, /* QuerySecurityContextToken */