wininet: Added NETCON_send support for schannel-based connections.

This commit is contained in:
Jacek Caban 2013-04-03 14:03:34 +02:00 committed by Alexandre Julliard
parent d473803765
commit 71ba6fcb9f
1 changed files with 44 additions and 2 deletions

View File

@ -1127,6 +1127,34 @@ DWORD NETCON_secure_connect(netconn_t *connection, server_t *server)
return res;
}
#ifndef SONAME_LIBSSL
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
{
SecBuffer bufs[4] = {
{conn->ssl_sizes.cbHeader, SECBUFFER_STREAM_HEADER, conn->ssl_buf},
{size, SECBUFFER_DATA, conn->ssl_buf+conn->ssl_sizes.cbHeader},
{conn->ssl_sizes.cbTrailer, SECBUFFER_STREAM_TRAILER, conn->ssl_buf+conn->ssl_sizes.cbHeader+size},
{0, SECBUFFER_EMPTY, NULL}
};
SecBufferDesc buf_desc = {SECBUFFER_VERSION, sizeof(bufs)/sizeof(*bufs), bufs};
SECURITY_STATUS res;
memcpy(bufs[1].pvBuffer, msg, size);
res = EncryptMessage(&conn->ssl_ctx, 0, &buf_desc, 0);
if(res != SEC_E_OK) {
WARN("EncryptMessage failed\n");
return FALSE;
}
if(send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
WARN("send failed\n");
return FALSE;
}
return TRUE;
}
#endif
/******************************************************************************
* NETCON_send
* Basically calls 'send()' unless we should use SSL
@ -1156,8 +1184,22 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags,
return ERROR_INTERNET_CONNECTION_ABORTED;
return ERROR_SUCCESS;
#else
FIXME("not supported on this platform\n");
return ERROR_NOT_SUPPORTED;
const BYTE *ptr = msg;
size_t chunk_size;
*sent = 0;
while(len) {
chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage);
if(!send_ssl_chunk(connection, ptr, chunk_size))
return ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
*sent += chunk_size;
ptr += chunk_size;
len -= chunk_size;
}
return ERROR_SUCCESS;
#endif
}
}