30#define TCP_CLOSE(_sck) closesocket(_sck)
31#define TCP_STRERROR "tcp error"
32#define TCP_SLEEP(_n) Sleep(_n)
33#define TCP_BLOCKS (WSAGetLastError() == WSAEWOULDBLOCK)
35#define TCP_CLOSE(_sck) close(_sck)
36#define TCP_STRERROR strerror(errno)
37#define TCP_SLEEP(_n) sleep(_n)
38#define TCP_BLOCKS (errno == EWOULDBLOCK)
42#define INADDR_NONE ((unsigned long) -1)
64static char * g_ssl_server =
NULL;
84 static int cur_stream_id = 0;
125 error(
"EncryptMessage failed: %d\n",
res);
190 bufs[0].cbBuffer = buf_len;
226 error(
"DecryptMessage failed: %d\n",
res);
346 uint32 new_length, end_offset, p_offset;
366 new_length = (
s->end -
s->data) +
length;
367 if (new_length >
s->size)
369 p_offset =
s->p -
s->data;
370 end_offset =
s->end -
s->data;
372 s->size = new_length;
373 s->p =
s->data + p_offset;
374 s->end =
s->data + end_offset;
459 error(
"Connection closed\n");
504 error(
"ensure_cred_handle failed: %ld\n",
res);
518 SIZE_T read_buf_size = 2048;
545 &
ctx, &out_desc, &attrs,
NULL);
564 out_buf.pvBuffer =
NULL;
572 memmove(
read_buf, (
BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
573 in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
576 in_bufs[1].cbBuffer = 0;
577 in_bufs[1].pvBuffer =
NULL;
583 if (in_bufs[0].cbBuffer + 1024 > read_buf_size)
592 in_bufs[0].pvBuffer =
read_buf = new_read_buf;
593 read_buf_size += 1024;
604 in_bufs[0].cbBuffer +=
size;
640 error(
"Failed to establish SSL connection: %08x (%u)\n",
status,
res);
654 char tcp_port_rdp_s[10];
656 if (!g_ssl_initialized)
661 g_ssl_initialized =
True;
692 error(
"tcp_tls_get_server_pubkey: QueryContextAttributesW() failed %ld\n",
status);
696 s->size =
cert->cbCertEncoded;
699 error(
"tcp_tls_get_server_pubkey: cert->cbCertEncoded = %ld\n",
cert->cbCertEncoded);
703 s->data =
s->p = (
unsigned char *)
xmalloc(
s->size);
706 s->end =
s->p +
s->size;
711 return (
s->size != 0);
727 char tcp_port_rdp_s[10];
737 error(
"getaddrinfo: %s\n", gai_strerror(
n));
800 option_len =
sizeof(option_value);
805 if (option_value < (1024 * 16))
807 option_value = 1024 * 16;
808 option_len =
sizeof(option_value);
858 g_ssl_initialized =
False;
868 static char ipaddr[32];
877 strcpy(ipaddr,
"127.0.0.1");
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
void scard_lock(int lock)
RD_BOOL tcp_tls_get_server_pubkey(STREAM s)
RD_BOOL tcp_tls_connect(void)
int ui_select(int rdp_socket)
void scard_unlock(int lock)
void * xrealloc(void *oldmem, size_t size)
void tcp_disconnect(void)
static struct stream g_out[STREAM_COUNT]
static struct stream g_in
void tcp_reset_state(void)
STREAM tcp_recv(STREAM s, uint32 length)
RD_BOOL tcp_connect(char *server)
RD_BOOL tcp_is_connected()
STREAM tcp_init(uint32 maxlen)
#define ERROR_NOT_ENOUGH_MEMORY
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
#define sprintf(buf, format,...)
static SecHandle compat_cred_handle
static BOOL cred_handle_initialized
static BOOL have_compat_cred_handle
static SecHandle cred_handle
static BOOL ensure_cred_handle(void)
#define ISC_REQ_MANUAL_CRED_VALIDATION
#define ISC_REQ_CONFIDENTIALITY
#define SecIsValidHandle(x)
#define ISC_REQ_ALLOCATE_MEMORY
#define SECPKG_CRED_OUTBOUND
#define SECBUFFER_STREAM_TRAILER
#define SECBUFFER_STREAM_HEADER
#define ISC_REQ_SEQUENCE_DETECT
#define ISC_REQ_REPLAY_DETECT
#define ISC_REQ_USE_SESSION_KEY
#define SecInvalidateHandle(x)
#define SECPKG_ATTR_STREAM_SIZES
#define SECBUFFER_VERSION
#define SP_PROT_TLS1_1PLUS_CLIENT
#define SECPKG_ATTR_SUPPORTED_PROTOCOLS
#define SCHANNEL_CRED_VERSION
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
namespace GUID const ADDRINFOEXW * hints
INT WSAAPI getpeername(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
DWORD grbitEnabledProtocols
SecPkgContext_StreamSizes ssl_sizes
static rfbScreenInfoPtr server
DWORD WINAPI GetLastError(void)
#define SEC_I_CONTEXT_EXPIRED
#define SEC_I_CONTINUE_NEEDED
#define SEC_E_INCOMPLETE_MESSAGE
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
SECURITY_STATUS WINAPI QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
SECURITY_STATUS WINAPI InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)