winhttp: Added schannel-based netconn_send implementation.

This commit is contained in:
Jacek Caban 2013-01-23 15:49:46 +01:00 committed by Alexandre Julliard
parent db22753a05
commit a3e15549d6
1 changed files with 47 additions and 2 deletions

View File

@ -909,18 +909,63 @@ fail:
return TRUE;
}
#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
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int flags, int *sent )
{
if (!netconn_connected( conn )) return FALSE;
if (conn->secure)
{
#ifdef SONAME_LIBSSL
if (flags) FIXME("SSL_write doesn't support any flags (%08x)\n", flags);
if (flags) FIXME("flags %08x not supported in SSL\n", flags);
*sent = pSSL_write( conn->ssl_conn, msg, len );
if (*sent < 1 && len) return FALSE;
return TRUE;
#else
return FALSE;
const BYTE *ptr = msg;
size_t chunk_size;
if (flags) FIXME("flags %08x not supported in SSL\n", flags);
*sent = 0;
while(len) {
chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
if(!send_ssl_chunk(conn, ptr, chunk_size))
return FALSE;
*sent += chunk_size;
ptr += chunk_size;
len -= chunk_size;
}
return TRUE;
#endif
}
if ((*sent = send( conn->socket, msg, len, flags )) == -1)