本文整理汇总了C++中FreeContextBuffer函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeContextBuffer函数的具体用法?C++ FreeContextBuffer怎么用?C++ FreeContextBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeContextBuffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NetlibInitSecurityProvider
HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrincipal)
{
HANDLE hSecurity = NULL;
if (mir_tstrcmpi(szProvider, _T("Basic")) == 0) {
NtlmHandleType* hNtlm = (NtlmHandleType*)mir_calloc(sizeof(NtlmHandleType));
hNtlm->szProvider = mir_tstrdup(szProvider);
SecInvalidateHandle(&hNtlm->hClientContext);
SecInvalidateHandle(&hNtlm->hClientCredential);
ntlmCnt++;
return hNtlm;
}
mir_cslock lck(csSec);
PSecPkgInfo ntlmSecurityPackageInfo;
bool isGSSAPI = mir_tstrcmpi(szProvider, _T("GSSAPI")) == 0;
const TCHAR *szProviderC = isGSSAPI ? _T("Kerberos") : szProvider;
SECURITY_STATUS sc = QuerySecurityPackageInfo((LPTSTR)szProviderC, &ntlmSecurityPackageInfo);
if (sc == SEC_E_OK) {
NtlmHandleType* hNtlm;
hSecurity = hNtlm = (NtlmHandleType*)mir_calloc(sizeof(NtlmHandleType));
hNtlm->cbMaxToken = ntlmSecurityPackageInfo->cbMaxToken;
FreeContextBuffer(ntlmSecurityPackageInfo);
hNtlm->szProvider = mir_tstrdup(szProvider);
hNtlm->szPrincipal = mir_tstrdup(szPrincipal ? szPrincipal : _T(""));
SecInvalidateHandle(&hNtlm->hClientContext);
SecInvalidateHandle(&hNtlm->hClientCredential);
ntlmCnt++;
}
return hSecurity;
}
开发者ID:ybznek,项目名称:miranda-ng,代码行数:35,代码来源:netlibsecurity.cpp
示例2: sizeof
void LSSLContext::Shutdown(LSockByteStream* SockByteStream, const TCHAR* TargetName)
{
//SSPI: отключение от сервера
//сначала выставим нужный статус у контекста
DWORD ShutdownToken = SCHANNEL_SHUTDOWN;
SecBufferDesc ShutDownBufferDesc;
SecBuffer ShutDownBuffers[1];
ShutDownBufferDesc.cBuffers = 1;
ShutDownBufferDesc.pBuffers = ShutDownBuffers;
ShutDownBufferDesc.ulVersion = SECBUFFER_VERSION;
ShutDownBuffers[0].pvBuffer = &ShutdownToken;
ShutDownBuffers[0].BufferType = SECBUFFER_TOKEN;
ShutDownBuffers[0].cbBuffer = sizeof(ShutdownToken);
//VERIFY(SEC_E_OK==ApplyControlToken(GetContextHandle(), &ShutDownBufferDesc));
//затем получим данные для отправки
ShutDownBuffers[0].BufferType = SECBUFFER_TOKEN;
ShutDownBuffers[0].pvBuffer = 0;
ShutDownBuffers[0].cbBuffer = 0;
/*VERIFY(SEC_E_OK==*/InitializeSecurityContext(&m_hUserCred, GetContextHandle(), const_cast<TCHAR*>(TargetName),
m_ReqContextAttr, 0, 0, 0, 0, 0,
&ShutDownBufferDesc, &m_ContextAttr, &m_ContextExpiry)/*)*/;
//ASSERT(ShutDownBuffers[0].pvBuffer&&ShutDownBuffers[0].cbBuffer);
//WS: отправим обработанные SCHANNEL данные
SockByteStream->RawSend(ShutDownBuffers[0].pvBuffer, ShutDownBuffers[0].cbBuffer);
FreeContextBuffer(ShutDownBuffers[0].pvBuffer);
ShutDownBuffers[0].pvBuffer=0;
ShutDownBuffers[0].cbBuffer=0;
}
开发者ID:RSATom,项目名称:light-pop3-smtp,代码行数:34,代码来源:SSLContext.cpp
示例3: EnumerateSecurityPackagesA
SECURITY_STATUS
WINAPI
EnumerateSecurityPackagesA(
PULONG pcPackages,
PSecPkgInfoA* ppPackageInfo
)
{
SECURITY_STATUS ret;
PSecPkgInfoW info = NULL;
ret = EnumerateSecurityPackagesW(pcPackages, &info);
if (ret == SEC_E_OK && *pcPackages && info)
{
/* *ppPackageInfo = thunk_PSecPkgInfoWToA(*pcPackages, info);
if (*pcPackages && !*ppPackageInfo)
{
*pcPackages = 0;
ret = SEC_E_INSUFFICIENT_MEMORY;
} */
FreeContextBuffer(info);
}
*ppPackageInfo = NULL;
UNIMPLEMENTED;
return ret;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:26,代码来源:sspi.c
示例4: TestEnumerateSecurityPackages
int TestEnumerateSecurityPackages(int argc, char* argv[])
{
int index;
ULONG cPackages;
SECURITY_STATUS status;
SecPkgInfo* pPackageInfo;
sspi_GlobalInit();
status = EnumerateSecurityPackages(&cPackages, &pPackageInfo);
if (status != SEC_E_OK)
{
sspi_GlobalFinish();
return -1;
}
_tprintf(_T("\nEnumerateSecurityPackages (%")_T(PRIu32)_T("):\n"), cPackages);
for (index = 0; index < (int) cPackages; index++)
{
_tprintf(_T("\"%s\", \"%s\"\n"), pPackageInfo[index].Name, pPackageInfo[index].Comment);
}
FreeContextBuffer(pPackageInfo);
sspi_GlobalFinish();
return 0;
}
开发者ID:99455125,项目名称:FreeRDP,代码行数:29,代码来源:TestEnumerateSecurityPackages.c
示例5: cleanup_sec_buffer
static apr_status_t
cleanup_sec_buffer(void *data)
{
FreeContextBuffer(data);
return APR_SUCCESS;
}
开发者ID:ceama,项目名称:freebsd,代码行数:7,代码来源:auth_kerb_sspi.c
示例6: SrvIsKerberosAvailable
BOOLEAN
SrvIsKerberosAvailable(
VOID
)
/*++
Routine Description:
Checks whether Kerberos is one of the supported security packages.
Arguments:
Return Value:
TRUE if Kerberos is available, FALSE if otherwise or error.
--*/
{
NTSTATUS Status;
ULONG PackageCount, Index;
PSecPkgInfoW Packages;
BOOLEAN FoundKerberos = FALSE;
//
// Get the list of packages from the security driver
//
Status = EnumerateSecurityPackages(
&PackageCount,
&Packages
);
if (!NT_SUCCESS(Status)) {
return(FALSE);
}
//
// Loop through the list looking for Kerberos
//
for (Index = 0; Index < PackageCount ; Index++ ) {
if (!_wcsicmp(Packages[Index].Name, MICROSOFT_KERBEROS_NAME_W)) {
FoundKerberos = TRUE;
break;
}
}
FreeContextBuffer(Packages);
return(FoundKerberos);
}
开发者ID:Gaikokujin,项目名称:WinNT4,代码行数:52,代码来源:access.c
示例7: ClientOff
int SSL_SOCKET :: ClientOff()
{
// Client wants to disconnect
SECURITY_STATUS ss;
Z<SecBuffer> OutBuffers(100);
DWORD dwType = SCHANNEL_SHUTDOWN;
OutBuffers[0].pvBuffer = &dwType;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
OutBuffers[0].cbBuffer = sizeof(dwType);
sbout.cBuffers = 1;
sbout.pBuffers = OutBuffers;
sbout.ulVersion = SECBUFFER_VERSION;
for(;;)
{
ss = ApplyControlToken(&hCtx, &sbout);
if (FAILED(ss))
return -1;
DWORD dwSSPIFlags;
DWORD dwSSPIOutFlags;
dwSSPIFlags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_RET_EXTENDED_ERROR | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM;
OutBuffers[0].pvBuffer = NULL;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
OutBuffers[0].cbBuffer = 0;
sbout.cBuffers = 1;
sbout.pBuffers = OutBuffers;
sbout.ulVersion = SECBUFFER_VERSION;
ss = InitializeSecurityContext(&hCred,&hCtx,NULL,dwSSPIFlags,0,SECURITY_NATIVE_DREP, NULL,0,&hCtx,&sbout,&dwSSPIOutFlags,0);
if (FAILED(ss))
return -1;
PBYTE pbMessage;
DWORD cbMessage;
pbMessage = (BYTE *)(OutBuffers[0].pvBuffer);
cbMessage = OutBuffers[0].cbBuffer;
if (pbMessage != NULL && cbMessage != 0)
{
int rval = ssend_p((char*)pbMessage, cbMessage);
FreeContextBuffer(pbMessage);
return rval;
}
break;
}
return 1;
}
开发者ID:kretzmoritz,项目名称:Archive,代码行数:52,代码来源:ssl.cpp
示例8: destroy
static int destroy(const struct plugin_interface *plugin)
{
protocol_interface *protocol = (protocol_interface*)plugin;
free(protocol->auth_username);
free(protocol->auth_password);
free(protocol->auth_repository);
free(g_sslBufferIn);
free(g_sslBufferOut);
FreeContextBuffer( secPackInfo );
return 0;
}
开发者ID:acml,项目名称:cvsnt,代码行数:13,代码来源:sserver_win32.cpp
示例9: test_kerberos
static void test_kerberos(void)
{
SecPkgInfoA *info;
TimeStamp ttl;
CredHandle cred;
SECURITY_STATUS status;
SEC_CHAR provider[] = {'K','e','r','b','e','r','o','s',0};
static const ULONG expected_flags =
SECPKG_FLAG_INTEGRITY
| SECPKG_FLAG_PRIVACY
| SECPKG_FLAG_TOKEN_ONLY
| SECPKG_FLAG_DATAGRAM
| SECPKG_FLAG_CONNECTION
| SECPKG_FLAG_MULTI_REQUIRED
| SECPKG_FLAG_EXTENDED_ERROR
| SECPKG_FLAG_IMPERSONATION
| SECPKG_FLAG_ACCEPT_WIN32_NAME
| SECPKG_FLAG_NEGOTIABLE
| SECPKG_FLAG_GSS_COMPATIBLE
| SECPKG_FLAG_LOGON
| SECPKG_FLAG_MUTUAL_AUTH
| SECPKG_FLAG_DELEGATION
| SECPKG_FLAG_READONLY_WITH_CHECKSUM;
static const ULONG optional_mask =
SECPKG_FLAG_RESTRICTED_TOKENS
| SECPKG_FLAG_APPCONTAINER_CHECKS;
status = QuerySecurityPackageInfoA(provider, &info);
ok(status == SEC_E_OK, "Kerberos package not installed, skipping test\n");
if(status != SEC_E_OK)
return;
ok( (info->fCapabilities & ~optional_mask) == expected_flags, "got %08x, expected %08x\n", info->fCapabilities, expected_flags );
ok( info->wVersion == 1, "got %u\n", info->wVersion );
ok( info->wRPCID == RPC_C_AUTHN_GSS_KERBEROS, "got %u\n", info->wRPCID );
ok( info->cbMaxToken >= 12000, "got %u\n", info->cbMaxToken );
ok( !lstrcmpA( info->Name, "Kerberos" ), "got %s\n", info->Name );
ok( !lstrcmpA( info->Comment, "Microsoft Kerberos V1.0" ), "got %s\n", info->Comment );
FreeContextBuffer( info );
status = AcquireCredentialsHandleA( NULL, provider, SECPKG_CRED_OUTBOUND, NULL,
NULL, NULL, NULL, &cred, &ttl );
todo_wine ok( status == SEC_E_OK, "AcquireCredentialsHandleA returned %08x\n", status );
if(status == SEC_E_OK)
FreeCredentialHandle( &cred );
}
开发者ID:bdidemus,项目名称:wine,代码行数:48,代码来源:secur32.c
示例10: kull_m_rpc_drsr_RpcSecurityCallback
void RPC_ENTRY kull_m_rpc_drsr_RpcSecurityCallback(void *Context)
{
RPC_STATUS rpcStatus;
SECURITY_STATUS secStatus;
PCtxtHandle data = NULL;
rpcStatus = I_RpcBindingInqSecurityContext(Context, (LPVOID *) &data);
if(rpcStatus == RPC_S_OK)
{
if(kull_m_rpc_drsr_g_sKey.SessionKey)
{
FreeContextBuffer(kull_m_rpc_drsr_g_sKey.SessionKey);
kull_m_rpc_drsr_g_sKey.SessionKeyLength = 0;
kull_m_rpc_drsr_g_sKey.SessionKey = NULL;
}
secStatus = QueryContextAttributes(data, SECPKG_ATTR_SESSION_KEY, (LPVOID) &kull_m_rpc_drsr_g_sKey);
if(secStatus != SEC_E_OK)
PRINT_ERROR(L"QueryContextAttributes %08x\n", secStatus);
}
else PRINT_ERROR(L"I_RpcBindingInqSecurityContext %08x\n", rpcStatus);
}
开发者ID:0x4e38,项目名称:mimikatz,代码行数:21,代码来源:kull_m_rpc_drsr.c
示例11: AcquireCreds
BOOL AcquireCreds()
{
SECURITY_STATUS ss;
TimeStamp Lifetime;
PSecPkgInfo pkgInfo;
// Set the default package to negotiate.
tstrcpy_s(g_lpPackageName, 1024, TEXT("Negotiate"));
// Initialize the security package.
ss = QuerySecurityPackageInfo(g_lpPackageName, &pkgInfo);
// get the max token size
g_cbMaxMessage = pkgInfo->cbMaxToken;
FreeContextBuffer(pkgInfo);
// set the max token sizes
g_pInBuf = (PBYTE)malloc(g_cbMaxMessage);
g_pOutBuf = (PBYTE)malloc(g_cbMaxMessage);
// get the security handles
ss = AcquireCredentialsHandle(
NULL,
g_lpPackageName,
SECPKG_CRED_INBOUND,
NULL,
NULL,
NULL,
NULL,
&hcred,
&Lifetime);
if (!SEC_SUCCESS(ss))
{
fprintf(stderr, "AcquireCreds failed: 0x%08x\n", ss);
return(FALSE);
}
return (TRUE);
}
开发者ID:trump0dump,项目名称:helpful,代码行数:40,代码来源:tokenc.cpp
示例12: tls_client_handshake
static int tls_client_handshake(URLContext *h)
{
TLSContext *c = h->priv_data;
TLSShared *s = &c->tls_shared;
SecBuffer outbuf;
SecBufferDesc outbuf_desc;
SECURITY_STATUS sspi_ret;
int ret;
init_sec_buffer(&outbuf, SECBUFFER_EMPTY, NULL, 0);
init_sec_buffer_desc(&outbuf_desc, &outbuf, 1);
c->request_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
sspi_ret = InitializeSecurityContext(&c->cred_handle, NULL, s->host, c->request_flags, 0, 0,
NULL, 0, &c->ctxt_handle, &outbuf_desc, &c->context_flags,
&c->ctxt_timestamp);
if (sspi_ret != SEC_I_CONTINUE_NEEDED) {
av_log(h, AV_LOG_ERROR, "Unable to create initial security context (0x%lx)\n", sspi_ret);
ret = AVERROR_UNKNOWN;
goto fail;
}
ret = ffurl_write(s->tcp, outbuf.pvBuffer, outbuf.cbBuffer);
FreeContextBuffer(outbuf.pvBuffer);
if (ret < 0 || ret != outbuf.cbBuffer) {
av_log(h, AV_LOG_ERROR, "Failed to send initial handshake data\n");
ret = AVERROR(EIO);
goto fail;
}
return tls_client_handshake_loop(h, 1);
fail:
DeleteSecurityContext(&c->ctxt_handle);
return ret;
}
开发者ID:Hero2000,项目名称:CainCamera,代码行数:39,代码来源:tls_schannel.c
示例13: tls_shutdown_client
static int tls_shutdown_client(URLContext *h)
{
TLSContext *c = h->priv_data;
TLSShared *s = &c->tls_shared;
int ret;
if (c->connected) {
SecBufferDesc BuffDesc;
SecBuffer Buffer;
SECURITY_STATUS sspi_ret;
SecBuffer outbuf;
SecBufferDesc outbuf_desc;
DWORD dwshut = SCHANNEL_SHUTDOWN;
init_sec_buffer(&Buffer, SECBUFFER_TOKEN, &dwshut, sizeof(dwshut));
init_sec_buffer_desc(&BuffDesc, &Buffer, 1);
sspi_ret = ApplyControlToken(&c->ctxt_handle, &BuffDesc);
if (sspi_ret != SEC_E_OK)
av_log(h, AV_LOG_ERROR, "ApplyControlToken failed\n");
init_sec_buffer(&outbuf, SECBUFFER_EMPTY, NULL, 0);
init_sec_buffer_desc(&outbuf_desc, &outbuf, 1);
sspi_ret = InitializeSecurityContext(&c->cred_handle, &c->ctxt_handle, s->host,
c->request_flags, 0, 0, NULL, 0, &c->ctxt_handle,
&outbuf_desc, &c->context_flags, &c->ctxt_timestamp);
if (sspi_ret == SEC_E_OK || sspi_ret == SEC_I_CONTEXT_EXPIRED) {
ret = ffurl_write(s->tcp, outbuf.pvBuffer, outbuf.cbBuffer);
FreeContextBuffer(outbuf.pvBuffer);
if (ret < 0 || ret != outbuf.cbBuffer)
av_log(h, AV_LOG_ERROR, "Failed to send close message\n");
}
c->connected = 0;
}
return 0;
}
开发者ID:Hero2000,项目名称:CainCamera,代码行数:38,代码来源:tls_schannel.c
示例14: test_EnumerateSecurityPackages
void test_EnumerateSecurityPackages(void)
{
uint32 cPackages;
SECURITY_STATUS status;
SecPkgInfo* pPackageInfo;
status = EnumerateSecurityPackages(&cPackages, &pPackageInfo);
if (status == SEC_E_OK)
{
int index;
printf("\nEnumerateSecurityPackages (%d):\n", cPackages);
for (index = 0; index < cPackages; index++)
{
printf("\"%s\", \"%s\"\n",
pPackageInfo[index].Name, pPackageInfo[index].Comment);
}
}
FreeContextBuffer(pPackageInfo);
}
开发者ID:ArvidNorr,项目名称:FreeRDP,代码行数:23,代码来源:test_sspi.c
示例15: sqCopyDescToken
/* Copies the data from a SecBufferDesc to dstBuf */
static sqInt sqCopyDescToken(sqSSL *ssl, SecBufferDesc sbd, char *dstBuf, sqInt dstLen) {
unsigned int i;
int result = 0;
if(ssl->loglevel) printf("sqCopyDescToken: \n");
for(i = 0; i < sbd.cBuffers; i++) {
SecBuffer *buf = sbd.pBuffers + i;
if(ssl->loglevel) printf("\t type=%d, size=%d\n", buf->BufferType, buf->cbBuffer);
if(buf->BufferType == SECBUFFER_TOKEN) {
int count = buf->cbBuffer;
if(count > dstLen) return SQSSL_BUFFER_TOO_SMALL;
memcpy(dstBuf, buf->pvBuffer, count);
result += count;
dstBuf += count;
dstLen -= count;
FreeContextBuffer(buf->pvBuffer);
}
if(buf->BufferType == SECBUFFER_EXTRA) {
/* XXXX: Preserve contents for the next round */
if(ssl->loglevel) printf("sqCopyDescToken: Unexpectedly encountered SECBUFFER_EXTRA\n");
}
}
return result;
}
开发者ID:JeanBaptisteArnaud,项目名称:RaspLocalDebug,代码行数:25,代码来源:sqWin32SSL.c
示例16: _sspiConnect
/*
* '_sspiConnect()' - Make an SSL connection. This function
* assumes a TCP/IP connection has already
* been successfully made
*/
BOOL /* O - 1 on success, 0 on failure */
_sspiConnect(_sspi_struct_t *conn, /* I - Client connection */
const CHAR *hostname) /* I - Server hostname */
{
PCCERT_CONTEXT serverCert; /* Server certificate */
DWORD dwSSPIFlags; /* SSL connection attributes we want */
DWORD dwSSPIOutFlags; /* SSL connection attributes we got */
TimeStamp tsExpiry; /* Time stamp */
SECURITY_STATUS scRet; /* Status */
DWORD cbData; /* Data count */
SecBufferDesc inBuffer; /* Array of SecBuffer structs */
SecBuffer inBuffers[2]; /* Security package buffer */
SecBufferDesc outBuffer; /* Array of SecBuffer structs */
SecBuffer outBuffers[1]; /* Security package buffer */
BOOL ok = TRUE; /* Return value */
serverCert = NULL;
dwSSPIFlags = ISC_REQ_SEQUENCE_DETECT |
ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY |
ISC_RET_EXTENDED_ERROR |
ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
/*
* Initiate a ClientHello message and generate a token.
*/
outBuffers[0].pvBuffer = NULL;
outBuffers[0].BufferType = SECBUFFER_TOKEN;
outBuffers[0].cbBuffer = 0;
outBuffer.cBuffers = 1;
outBuffer.pBuffers = outBuffers;
outBuffer.ulVersion = SECBUFFER_VERSION;
scRet = InitializeSecurityContext(&conn->creds, NULL, TEXT(""), dwSSPIFlags,
0, SECURITY_NATIVE_DREP, NULL, 0, &conn->context,
&outBuffer, &dwSSPIOutFlags, &tsExpiry);
if (scRet != SEC_I_CONTINUE_NEEDED)
{
DEBUG_printf(("_sspiConnect: InitializeSecurityContext(1) failed: %x", scRet));
ok = FALSE;
goto cleanup;
}
/*
* Send response to server if there is one.
*/
if (outBuffers[0].cbBuffer && outBuffers[0].pvBuffer)
{
cbData = send(conn->sock, outBuffers[0].pvBuffer, outBuffers[0].cbBuffer, 0);
if ((cbData == SOCKET_ERROR) || !cbData)
{
DEBUG_printf(("_sspiConnect: send failed: %d", WSAGetLastError()));
FreeContextBuffer(outBuffers[0].pvBuffer);
DeleteSecurityContext(&conn->context);
ok = FALSE;
goto cleanup;
}
DEBUG_printf(("_sspiConnect: %d bytes of handshake data sent", cbData));
/*
* Free output buffer.
*/
FreeContextBuffer(outBuffers[0].pvBuffer);
outBuffers[0].pvBuffer = NULL;
}
dwSSPIFlags = ISC_REQ_MANUAL_CRED_VALIDATION |
ISC_REQ_SEQUENCE_DETECT |
ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY |
ISC_RET_EXTENDED_ERROR |
ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
conn->decryptBufferUsed = 0;
/*
* Loop until the handshake is finished or an error occurs.
*/
scRet = SEC_I_CONTINUE_NEEDED;
while(scRet == SEC_I_CONTINUE_NEEDED ||
scRet == SEC_E_INCOMPLETE_MESSAGE ||
scRet == SEC_I_INCOMPLETE_CREDENTIALS)
{
if ((conn->decryptBufferUsed == 0) || (scRet == SEC_E_INCOMPLETE_MESSAGE))
{
if (conn->decryptBufferLength <= conn->decryptBufferUsed)
{
//.........这里部分代码省略.........
开发者ID:jianglei12138,项目名称:ghostscript,代码行数:101,代码来源:sspi.c
示例17: ServerEstablishContext
//.........这里部分代码省略.........
OutputDesc.ulVersion = SECBUFFER_VERSION;
OutputDesc.pBuffers = &SendTokenBuffer;
printf("ASC flags requested (0x%08x):\n", AscFlags);
DumpAscReqFlags(AscFlags);
do
{
dwError = RecvToken(nSocket, &RecvTokenBuffer);
BAIL_ON_ERROR(dwError);
printf("RECEIVED:\n");
DumpBuffer(RecvTokenBuffer.pvBuffer, RecvTokenBuffer.cbBuffer);
DumpNtlmMessage(RecvTokenBuffer.pvBuffer, RecvTokenBuffer.cbBuffer);
printf("\n");
RecvTokenBuffer.BufferType = SECBUFFER_TOKEN;
SendTokenBuffer.cbBuffer = 0;
SendTokenBuffer.pvBuffer = NULL;
SendTokenBuffer.BufferType = SECBUFFER_TOKEN;
// we need to use dwLoopErr in this case because we may get
// back a "continue" command. In those cases, we still
// need dwError to be used and set seperatly based on other
// calls.
dwLoopError = AcceptSecurityContext(
pServerCreds,
pContextHandle,
&InputDesc,
AscFlags,
SECURITY_NATIVE_DREP,
pContext,
&OutputDesc,
&nRetFlags,
&Expiry
);
if (SEC_E_OK != dwLoopError && SEC_I_CONTINUE_NEEDED != dwLoopError)
{
dwError = dwLoopError;
BAIL_ON_ERROR(dwError);
}
if (SEC_I_CONTINUE_NEEDED == dwLoopError)
{
printf("Context partially accepted...\n");
DumpBuffer(SendTokenBuffer.pvBuffer, SendTokenBuffer.cbBuffer);
DumpNtlmMessage(SendTokenBuffer.pvBuffer, SendTokenBuffer.cbBuffer);
if (nRetFlags)
{
printf("ASC flags returned (0x%08x):\n", nRetFlags);
DumpAscRetFlags(nRetFlags);
}
printf("\n");
}
else
{
printf("Context FULLY accepted!\n");
printf("ASC flags returned (0x%08x):\n", nRetFlags);
DumpAscRetFlags(nRetFlags);
printf("\n");
}
nContextAcquired = 1;
pContextHandle = pContext;
free(RecvTokenBuffer.pvBuffer);
RecvTokenBuffer.pvBuffer = NULL;
if (SendTokenBuffer.cbBuffer != 0)
{
dwError = SendToken(nSocket, &SendTokenBuffer);
BAIL_ON_ERROR(dwError);
FreeContextBuffer(SendTokenBuffer.pvBuffer);
SendTokenBuffer.pvBuffer = NULL;
}
} while (dwLoopError == SEC_I_CONTINUE_NEEDED);
finish:
return dwError;
error:
if (RecvTokenBuffer.pvBuffer)
{
free(RecvTokenBuffer.pvBuffer);
RecvTokenBuffer.pvBuffer = NULL;
}
if (SendTokenBuffer.cbBuffer)
{
FreeContextBuffer(SendTokenBuffer.pvBuffer);
SendTokenBuffer.pvBuffer = NULL;
SendTokenBuffer.cbBuffer = 0;
}
if (nContextAcquired)
{
DeleteSecurityContext(pContext);
}
goto finish;
}
开发者ID:Brainiarc7,项目名称:pbis,代码行数:101,代码来源:sspi-server.c
示例18: credssp_server_authenticate
//.........这里部分代码省略.........
have_pub_key_auth = true;
sspi_SecBufferFree(&credssp->negoToken);
credssp->negoToken.pvBuffer = NULL;
credssp->negoToken.cbBuffer = 0;
if (credssp->table->QueryContextAttributes(&credssp->context, SECPKG_ATTR_SIZES, &credssp->ContextSizes) != SEC_E_OK)
{
printf("QueryContextAttributes SECPKG_ATTR_SIZES failure\n");
return 0;
}
if (have_pub_key_auth)
{
uint8* p;
SecBuffer Buffers[2];
SecBufferDesc Message;
Buffers[0].BufferType = SECBUFFER_DATA; /* TLS Public Key */
Buffers[1].BufferType = SECBUFFER_TOKEN; /* Signature */
Buffers[0].cbBuffer = credssp->PublicKey.cbBuffer;
Buffers[0].pvBuffer = xmalloc(Buffers[0].cbBuffer);
memcpy(Buffers[0].pvBuffer, credssp->PublicKey.pvBuffer, Buffers[0].cbBuffer);
Buffers[1].cbBuffer = credssp->ContextSizes.cbMaxSignature;
Buffers[1].pvBuffer = xzalloc(Buffers[1].cbBuffer);
Message.cBuffers = 2;
Message.ulVersion = SECBUFFER_VERSION;
Message.pBuffers = (PSecBuffer) &Buffers;
p = (uint8*) Buffers[0].pvBuffer;
p[0]++; /* Public Key +1 */
sspi_SecBufferAlloc(&credssp->pubKeyAuth, Buffers[0].cbBuffer + Buffers[1].cbBuffer);
credssp->table->EncryptMessage(&credssp->context, 0, &Message, 0);
p = (uint8*) credssp->pubKeyAuth.pvBuffer;
memcpy(p, Buffers[1].pvBuffer, Buffers[1].cbBuffer); /* Message Signature */
memcpy(&p[Buffers[1].cbBuffer], Buffers[0].pvBuffer, Buffers[0].cbBuffer); /* Encrypted Public Key */
}
if (status == SEC_I_COMPLETE_NEEDED)
status = SEC_E_OK;
else if (status == SEC_I_COMPLETE_AND_CONTINUE)
status = SEC_I_CONTINUE_NEEDED;
}
/* send authentication token */
#ifdef WITH_DEBUG_CREDSSP
printf("Sending Authentication Token\n");
credssp_buffer_print(credssp);
#endif
credssp_send(credssp);
credssp_buffer_free(credssp);
if (status != SEC_I_CONTINUE_NEEDED)
break;
have_context = true;
}
/* Receive encrypted credentials */
if (credssp_recv(credssp) < 0)
return -1;
if (status != SEC_E_OK)
{
printf("AcceptSecurityContext status: 0x%08X\n", status);
return 0;
}
status = credssp->table->ImpersonateSecurityContext(&credssp->context);
if (status != SEC_E_OK)
{
printf("ImpersonateSecurityContext status: 0x%08X\n", status);
return 0;
}
else
{
status = credssp->table->RevertSecurityContext(&credssp->context);
if (status != SEC_E_OK)
{
printf("RevertSecurityContext status: 0x%08X\n", status);
return 0;
}
}
FreeContextBuffer(pPackageInfo);
return 1;
}
开发者ID:mattymo,项目名称:FreeRDP,代码行数:101,代码来源:credssp.c
示例19: sserver_auth_protocol_connect
int sserver_auth_protocol_connect(const struct protocol_interface *protocol, const char *auth_string)
{
CScramble scramble;
char *tmp;
int certonly;
char *client_version = NULL;
char keyfile[256];
const char *hostname = NULL;
if (!strcmp (auth_string, "BEGIN SSL VERIFICATION REQUEST"))
sserver_protocol_interface.verify_only = 1;
else if (!strcmp (auth_string, "BEGIN SSL AUTH REQUEST"))
sserver_protocol_interface.verify_only = 0;
else
return CVSPROTO_NOTME;
write(current_server()->out_fd,SSERVER_INIT_STRING,sizeof(SSERVER_INIT_STRING)-1);
if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","CertificatesOnly",keyfile,sizeof(keyfile)))
certonly = atoi(keyfile);
if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","ServerDnsName",keyfile,sizeof(keyfile)))
hostname = keyfile;
if(!ServerAuthenticate(hostname))
return CVSPROTO_AUTHFAIL;
QueryContextAttributes(&contextHandle,SECPKG_ATTR_STREAM_SIZES,&secSizes);
g_sslBufferInPos=g_sslBufferOutPos=0;
g_sslBufferInLen=g_sslBufferOutLen=0;
set_encrypted_channel(1); /* Error must go through us now */
PCERT_CONTEXT sc;
PCCERT_CHAIN_CONTEXT pcc;
CERT_SIMPLE_CHAIN *psc;
CERT_CHAIN_PARA para = { sizeof(CERT_CHAIN_PARA) };
DWORD trust,rc;
BOOL cert = FALSE;
rc = QueryContextAttributes(&contextHandle,SECPKG_ATTR_REMOTE_CERT_CONTEXT,&sc);
if(rc && rc!=SEC_E_NO_CREDENTIALS)
server_error(1,"Couldn't get client certificate");
if(rc!=SEC_E_NO_CREDENTIALS) /* The client doesn't have to send us a cert. as cvs uses passwords normally */
{
if(!CertGetCertificateChain(NULL, sc, NULL, NULL, ¶, 0, NULL, &pcc))
server_error(1,"Couldn't get client certificate chain");
psc = pcc->rgpChain[0];
trust = psc->TrustStatus.dwErrorStatus;
if (trust)
{
if (trust & (CERT_TRUST_IS_PARTIAL_CHAIN | CERT_TRUST_IS_UNTRUSTED_ROOT))
server_error(1,"Client sent self signed certificate");
else if (trust & (CERT_TRUST_IS_NOT_TIME_VALID))
server_error(1,"Client certificate expired");
else
server_error(1,"Client certificate verification failed - %08x",trust);
}
CertFreeCertificateChain(pcc);
FreeContextBuffer(sc);
cert = TRUE;
}
/* Get the three important pieces of information in order. */
/* See above comment about error handling. */
/* get version, if sent. 1.0 clients didn't have this handshake so we have to handle that. */
server_getline (protocol, &client_version, MAX_PATH);
if(strncmp(client_version,"SSERVER-CLIENT ",15))
{
sserver_protocol_interface.auth_repository = client_version;
client_version = NULL;
}
else
server_getline (protocol, &sserver_protocol_interface.auth_repository, MAX_PATH);
server_getline (protocol, &sserver_protocol_interface.auth_username, MAX_PATH);
server_getline (protocol, &sserver_protocol_interface.auth_password, MAX_PATH);
if(client_version) free(client_version);
client_version = NULL;
/* ... and make sure the protocol ends on the right foot. */
/* See above comment about error handling. */
server_getline(protocol, &tmp, MAX_PATH);
if (strcmp (tmp,
sserver_protocol_interface.verify_only ?
"END SSL VERIFICATION REQUEST" : "END SSL AUTH REQUEST")
!= 0)
{
server_printf ("bad auth protocol end: %s\n", tmp);
free(tmp);
return CVSPROTO_FAIL;
}
strcpy(sserver_protocol_interface.auth_password, scramble.Unscramble(sserver_protocol_interface.auth_password));
//.........这里部分代码省略.........
开发者ID:acml,项目名称:cvsnt,代码行数:101,代码来源:sserver_win32.cpp
示例20: sserver_connect
//.........这里部分代码省略.........
strncpy(crypt_password,scramble.Scramble(current_server()->current_root->password),sizeof(crypt_password));
else
{
if(sserver_get_user_password(username,current_server()->current_root->hostname,current_server()->current_root->port,current_server()->current_root->directory,crypt_password,sizeof(crypt_password)))
{
/* Using null password - trace something out here */
server_error(0,"Using an empty password; you may need to do 'cvs login' with a real password\n");
strncpy(crypt_password,scramble.Scramble(""),sizeof(crypt_password));
}
}
if(sserver_version == 0) /* Pre-CVSNT had no version check */
{
if(tcp_printf("%s\n",begin_request)<0)
return CVSPROTO_FAIL;
for(;;)
{
*server_version='\0';
if((l=tcp_readline(server_version,sizeof(server_version))<0))
return CVSPROTO_FAIL;
if(*server_version)
break;
#ifdef _WIN32
Sleep(10);
#else
usleep(10);
#endif
}
if(strncmp(server_version,"SSERVER ",8))
{
server_error(0,"%s\n",server_version);
return CVSPROTO_FAIL;
}
if(strncmp(server_version+8,"1.0 ",4))
send_client_version = true;
}
if(!ClientAuthenticate(cert,current_server()->current_root->hostname))
return CVSPROTO_AUTHFAIL;
QueryContextAttributes(&contextHandle,SECPKG_ATTR_STREAM_SIZES,&secSizes);
PCERT_CONTEXT sc;
PCCERT_CHAIN_CONTEXT pcc;
CERT_SIMPLE_CHAIN *psc;
CERT_CHAIN_PARA para = { sizeof(CERT_CHAIN_PARA) };
DWORD trust,rc;
rc = QueryContextAttributes(&contextHandle,SECPKG_ATTR_REMOTE_CERT_CONTEXT,&sc);
if(rc)
server_error(1,"Couldn't get server certificate");
if(!CertGetCertificateChain(NULL, sc, NULL, NULL, ¶, 0, NULL, &pcc))
server_error(1,"Couldn't get server certificate chain");
psc = pcc->rgpChain[0];
trust = psc->TrustStatus.dwErrorStatus;
if (trust)
{
if (trust & (CERT_TRUST_IS_PARTIAL_CHAIN | CERT_TRUST_IS_UNTRUSTED_ROOT))
; // Seld signed
else if (trust & (CERT_TRUST_IS_NOT_TIME_VALID))
server_error(1,"Server certificate expired");
else
server_error(1,"Server certificate verification failed - %08x",trust);
}
if(strict)
{
char certname[256];
CertGetNameString(sc, CERT_NAME_DNS_TYPE, 0, NULL, certname, sizeof(certname));
if(strcasecmp(certname,current_server()->current_root->hostname))
server_error(1, "Certificate CommonName '%s' does not match server name '%s'\n",certname,current_server()->current_root->hostname);
}
CertFreeCertificateChain(pcc);
FreeContextBuffer(sc);
g_sslBufferInPos=g_sslBufferOutPos=0;
g_sslBufferInLen=g_sslBufferOutLen=0;
if(sserver_version == 1)
{
if(sserver_printf("%s\n",begin_request)<0)
return CVSPROTO_FAIL;
}
// For server versions 1.1+ send CLIENT_VERSION_STRING
if(send_client_version && sserver_printf(SSERVER_CLIENT_VERSION_STRING)<0)
return CVSPROTO_FAIL;
if(sserver_printf("%s\n%s\n",current_server()->current_root->directory,username)<0)
return CVSPROTO_FAIL;
if(sserver_printf("%s\n",crypt_password)<0)
return CVSPROTO_FAIL;
if(sserver_printf("%s\n",end_request)<0)
return CVSPROTO_FAIL;
return CVSPROTO_SUCCESS;
}
开发者ID:acml,项目名称:cvsnt,代码行数:101,代码来源:sserver_win32.cpp
注:本文中的FreeContextBuffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论