winhttp: Added schannel-based netconn_send implementation.
This commit is contained in:
parent
db22753a05
commit
a3e15549d6
|
@ -909,18 +909,63 @@ fail:
|
||||||
return TRUE;
|
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 )
|
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int flags, int *sent )
|
||||||
{
|
{
|
||||||
if (!netconn_connected( conn )) return FALSE;
|
if (!netconn_connected( conn )) return FALSE;
|
||||||
if (conn->secure)
|
if (conn->secure)
|
||||||
{
|
{
|
||||||
#ifdef SONAME_LIBSSL
|
#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 );
|
*sent = pSSL_write( conn->ssl_conn, msg, len );
|
||||||
if (*sent < 1 && len) return FALSE;
|
if (*sent < 1 && len) return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
if ((*sent = send( conn->socket, msg, len, flags )) == -1)
|
if ((*sent = send( conn->socket, msg, len, flags )) == -1)
|
||||||
|
|
Loading…
Reference in New Issue