2019-08-09 13:52:14 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#include <wincrypt.h>
|
|
|
|
#include <wintrust.h>
|
|
|
|
#include <schannel.h>
|
|
|
|
|
|
|
|
#define SECURITY_WIN32
|
|
|
|
#include <security.h>
|
|
|
|
#include <sspi.h>
|
|
|
|
|
2019-08-25 21:27:12 +03:00
|
|
|
#define vsc_init_resp_buff_size 44000
|
|
|
|
|
2019-08-09 13:52:14 +03:00
|
|
|
#define IO_BUFFER_SIZE 0x10000
|
|
|
|
|
|
|
|
#define TLS_MAX_BUFSIZ 32768
|
|
|
|
|
|
|
|
// Define here to be sure
|
|
|
|
#define SP_PROT_TLS1_2_CLIENT 0x00000800
|
|
|
|
|
|
|
|
|
2019-08-10 11:05:59 +03:00
|
|
|
static struct TlsContext new_tls_context();
|
|
|
|
|
|
|
|
static void vschannel_init();
|
|
|
|
|
|
|
|
static void vschannel_cleanup();
|
|
|
|
|
2019-08-25 21:27:12 +03:00
|
|
|
static INT request(INT iport, CHAR *host, CHAR *req, CHAR **out);
|
2019-08-09 13:52:14 +03:00
|
|
|
|
2019-08-11 14:13:33 +03:00
|
|
|
static SECURITY_STATUS https_make_request(
|
2019-08-25 21:27:12 +03:00
|
|
|
CHAR *req, CHAR **out, int *length);
|
2019-08-11 14:13:33 +03:00
|
|
|
|
|
|
|
static INT connect_to_server(CHAR *host, INT port_number);
|
2019-08-09 13:52:14 +03:00
|
|
|
|
2019-08-11 14:13:33 +03:00
|
|
|
static LONG disconnect_from_server();
|
2019-08-09 13:52:14 +03:00
|
|
|
|
|
|
|
static SECURITY_STATUS perform_client_handshake(
|
2019-08-11 14:13:33 +03:00
|
|
|
CHAR *host, SecBuffer *pExtraData);
|
2019-08-09 13:52:14 +03:00
|
|
|
|
|
|
|
static SECURITY_STATUS client_handshake_loop(
|
|
|
|
BOOL fDoInitialRead, SecBuffer *pExtraData);
|
|
|
|
|
|
|
|
static DWORD verify_server_certificate(
|
|
|
|
PCCERT_CONTEXT pServerCert, PSTR host, DWORD dwCertFlags);
|
|
|
|
|
2019-08-11 14:13:33 +03:00
|
|
|
static SECURITY_STATUS create_credentials();
|
2019-08-09 13:52:14 +03:00
|
|
|
|
2019-08-11 14:13:33 +03:00
|
|
|
static void get_new_client_credentials();
|