57 char*
mod,
int mod_len,
char*
exp,
int exp_len);
59rdssl_sign_ok(
char* e_data,
int e_len,
char* n_data,
int n_len,
60 char* sign_data,
int sign_len,
char* sign_data2,
int sign_len2,
char* testkey);
111#define SEC_MODULUS_SIZE 64
115 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
116 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x5c, 0x00,
117 0x52, 0x53, 0x41, 0x31, 0x48, 0x00, 0x00, 0x00,
118 0x00, 0x02, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
119 0x01, 0x00, 0x01, 0x00, 0x79, 0x6f, 0xb4, 0xdf,
120 0xa6, 0x95, 0xb9, 0xa9, 0x61, 0xe3, 0xc4, 0x5e,
121 0xff, 0x6b, 0xd8, 0x81, 0x8a, 0x12, 0x4a, 0x93,
122 0x42, 0x97, 0x18, 0x93, 0xac, 0xd1, 0x3a, 0x38,
123 0x3c, 0x68, 0x50, 0x19, 0x31, 0xb6, 0x84, 0x51,
124 0x79, 0xfb, 0x1c, 0xe7, 0xe3, 0x99, 0x20, 0xc7,
125 0x84, 0xdf, 0xd1, 0xaa, 0xb5, 0x15, 0xef, 0x47,
126 0x7e, 0xfc, 0x88, 0xeb, 0x29, 0xc3, 0x27, 0x5a,
127 0x35, 0xf8, 0xfd, 0xaa, 0x00, 0x00, 0x00, 0x00,
128 0x00, 0x00, 0x00, 0x00,
129 0x08, 0x00, 0x48, 0x00,
130 0x32, 0x3b, 0xde, 0x6f, 0x18, 0x97, 0x1e, 0xc3,
131 0x6b, 0x2b, 0x2d, 0xe4, 0xfc, 0x2d, 0xa2, 0x8e,
132 0x32, 0x3c, 0xf3, 0x1b, 0x24, 0x90, 0x57, 0x4d,
133 0x8e, 0xe4, 0x69, 0xfc, 0x16, 0x8d, 0x41, 0x92,
134 0x78, 0xc7, 0x9c, 0xb4, 0x26, 0xff, 0xe8, 0x3e,
135 0xa1, 0x8a, 0xf5, 0x57, 0xc0, 0x7f, 0x3e, 0x21,
136 0x17, 0x32, 0x30, 0x6f, 0x79, 0xe1, 0x36, 0xcd,
137 0xb6, 0x8e, 0xbe, 0x57, 0x57, 0xd2, 0xa9, 0x36
163 for (
i = 0;
i < 3;
i++)
240 uint8 pre_master_secret[48];
241 uint8 master_secret[48];
245 memcpy(pre_master_secret, client_random, 24);
246 memcpy(pre_master_secret + 24, server_random, 24);
249 sec_hash_48(master_secret, pre_master_secret, client_random, server_random,
'A');
250 sec_hash_48(key_block, master_secret, client_random, server_random,
'X');
259 if (rc4_key_size == 1)
261 DEBUG((
"40-bit encryption enabled\n"));
269 DEBUG((
"rc_4_key_size == %d, 128-bit encryption enabled\n", rc4_key_size));
289 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
291 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
296 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
297 92, 92, 92, 92, 92, 92, 92,
298 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
299 92, 92, 92, 92, 92, 92, 92
450 flags &= ~SEC_ENCRYPT;
454 DEBUG((
"Sending encrypted packet:\n"));
501 int length = 162 + 76 + 12 + 4;
601 uint32 magic, modulus_len;
606 error(
"RSA magic 0x%x\n", magic);
614 error(
"Bad server public key size (%u bits)\n", modulus_len * 8);
645 DEBUG_RDP5((
"key signature doesn't match test key\n"));
655 uint32 crypt_level, random_len, rsa_info_len;
658 BYTE *server_public_key;
664 if (crypt_level == 0)
682 end =
s->p + rsa_info_len;
689 DEBUG_RDP5((
"We're going for the RDP4-style encryption\n"));
724 DEBUG_RDP5((
"We're going for the RDP5-style encryption\n"));
728 error(
"Server didn't send enough X509 certificates\n");
731 for (; certcount > 2; certcount--)
736 DEBUG_RDP5((
"Ignored certs left: %d\n", certcount));
738 DEBUG_RDP5((
"Ignored Certificate length is %d\n", ignorelen));
741 if (ignorecert ==
NULL)
743 DEBUG_RDP5((
"got a bad cert: this will probably screw up the rest of the communication\n"));
746#ifdef WITH_DEBUG_RDP5
747 DEBUG_RDP5((
"cert #%d (ignored):\n", certcount));
748 rdssl_cert_print_fp(
stdout, ignorecert);
760 DEBUG_RDP5((
"CA Certificate length is %d\n", cacert_len));
765 error(
"Couldn't load CA Certificate from server\n");
769 DEBUG_RDP5((
"Certificate length is %d\n", cert_len));
772 if (
NULL == server_cert)
775 error(
"Couldn't load Certificate from server\n");
782 error(
"Security error CA Certificate invalid\n");
788 if (
NULL == server_public_key)
790 DEBUG_RDP5((
"Didn't parse X509 correctly\n"));
798 error(
"Bad server public key size (%u bits)\n",
806 error(
"Problem extracting RSA exponent, modulus");
829 DEBUG((
"Failed to parse crypt info\n"));
832 DEBUG((
"Generating client random\n"));
867 while (
s->p <
s->end)
952 if (
s->p[0] == 0 &&
s->p[1] == 4)
1015 mcs_data.
size = 512;
std::map< E_MODULE, HMODULE > mod
ACPI_SIZE strlen(const char *String)
void channel_process(STREAM s, uint16 mcs_channel)
#define SEC_EXPONENT_SIZE
#define SEC_TAG_CLI_CRYPT
#define SEC_REDIRECTION_PKT
#define SEC_TAG_SRV_CRYPT
#define SEC_TAG_SRV_CHANNELS
#define SEC_CC_REDIRECT_VERSION_3
#define SEC_CC_REDIRECT_SESSIONID_FIELD_VALID
#define SEC_CC_REDIRECTION_SUPPORTED
#define SEC_TAG_CLI_CHANNELS
#define SEC_MAX_MODULUS_SIZE
#define SEC_TAG_CLI_CLUSTER
#define MCS_GLOBAL_CHANNEL
void licence_process(STREAM s)
RD_BOOL mcs_connect_start(char *server, char *username, char *domain, char *password, RD_BOOL reconnect, uint32 *selected_protocol)
STREAM mcs_init(int length)
void mcs_reset_state(void)
STREAM mcs_recv(uint16 *channel, uint8 *rdpver)
void mcs_disconnect(void)
void mcs_send_to_channel(STREAM s, uint16 channel)
RD_BOOL mcs_connect_finalize(STREAM mcs_data)
#define out_uint32_le(s, v)
#define out_uint32_be(s, v)
#define s_pop_layer(s, h)
#define s_push_layer(s, h, n)
#define in_uint16_le(s, v)
#define out_uint16_be(s, v)
#define in_uint8p(s, v, n)
#define in_uint8a(s, v, n)
#define out_uint16_le(s, v)
#define out_uint8p(s, v, n)
#define in_uint32_le(s, v)
#define out_uint8a(s, v, n)
void scard_lock(int lock)
void unimpl(char *format,...)
void hexdump(unsigned char *p, unsigned int len)
void rdp_out_unistr(STREAM s, char *string, int len)
void scard_unlock(int lock)
void generate_random(uint8 *random)
static RD_BOOL sec_parse_public_sig(STREAM s, uint32 len, uint8 *modulus, uint8 *exponent)
void sec_process_mcs_data(STREAM s)
static uint32 g_server_public_key_len
void rdssl_rc4_crypt(void *rc4_info, char *in_data, char *out_data, int len)
int rdssl_sign_ok(char *e_data, int e_len, char *n_data, int n_len, char *sign_data, int sign_len, char *sign_data2, int sign_len2, char *testkey)
static uint8 g_sec_sign_key[16]
void sec_hash_sha1_16(uint8 *out, uint8 *in, uint8 *salt1)
void rdssl_rkey_free(uint8 *rkey)
void * rdssl_rc4_info_create(void)
static void sec_generate_keys(uint8 *client_random, uint8 *server_random, int rc4_key_size)
int rdssl_rkey_get_exp_mod(uint8 *rkey, uint8 *exponent, uint32 max_exp_len, uint8 *modulus, uint32 max_mod_len)
void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt)
static void * g_rc4_decrypt_key
void rdssl_sha1_clear(void *sha1_info)
static uint8 g_sec_encrypt_update_key[16]
static void sec_make_40bit(uint8 *key)
void rdssl_sha1_transform(void *sha1_info, char *data, int len)
void buf_out_uint32(uint8 *buffer, uint32 value)
void rdssl_rc4_set_key(void *rc4_info, char *key, int len)
PCCERT_CONTEXT rdssl_cert_read(uint8 *data, uint32 len)
static uint8 g_sec_crypted_random[SEC_MAX_MODULUS_SIZE]
static RD_BOOL sec_parse_public_key(STREAM s, uint8 *modulus, uint8 *exponent)
void rdssl_md5_clear(void *md5_info)
static void sec_out_mcs_data(STREAM s, uint32 selected_protocol)
int g_keyboard_functionkeys
static uint8 g_sec_decrypt_key[16]
RD_BOOL g_licence_error_result
void rdssl_cert_free(PCCERT_CONTEXT context)
static int g_sec_encrypt_use_count
void rdssl_sha1_info_delete(void *sha1_info)
void rdssl_md5_transform(void *md5_info, char *data, int len)
void sec_send(STREAM s, uint32 flags)
static RD_BOOL sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size, uint8 **server_random, uint8 *modulus, uint8 *exponent)
RD_BOOL sec_connect(char *server, char *username, char *domain, char *password, RD_BOOL reconnect)
uint16 g_server_rdp_version
static int g_sec_decrypt_use_count
RDP_VERSION g_rdp_version
void sec_send_to_channel(STREAM s, uint32 flags, uint16 channel)
void rdssl_sha1_complete(void *sha1_info, char *data)
void * rdssl_sha1_info_create(void)
void sec_hash_to_string(char *out, int out_size, uint8 *in, int in_size)
void sec_reset_state(void)
void rdssl_md5_complete(void *md5_info, char *data)
static uint8 g_sec_decrypt_update_key[16]
void sec_disconnect(void)
RD_BOOL rdssl_certs_ok(PCCERT_CONTEXT server_cert, PCCERT_CONTEXT cacert)
uint8 * rdssl_cert_to_rkey(PCCERT_CONTEXT cert, uint32 *key_len)
uint8 g_client_random[SEC_RANDOM_SIZE]
static uint8 g_sec_encrypt_key[16]
static void sec_update(uint8 *key, uint8 *update_key)
uint32 g_redirect_session_id
static void sec_establish_key(void)
static void sec_rsa_encrypt(uint8 *out, uint8 *in, int len, uint32 modulus_size, uint8 *modulus, uint8 *exponent)
void rdssl_md5_info_delete(void *md5_info)
void sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2)
static uint8 g_testkey[176]
STREAM sec_recv(uint8 *rdpver)
static void sec_process_srv_info(STREAM s)
STREAM sec_init(uint32 flags, int maxlen)
unsigned int g_num_channels
static void sec_process_crypt_info(STREAM s)
RD_BOOL g_console_session
static void sec_encrypt(uint8 *data, int length)
void sec_sign(uint8 *signature, int siglen, uint8 *session_key, int keylen, uint8 *data, int datalen)
void * rdssl_md5_info_create(void)
static void * g_rc4_encrypt_key
void sec_decrypt(uint8 *data, int length)
void rdssl_rc4_info_delete(void *rc4_info)
int rdssl_mod_exp(char *out, int out_len, char *in, int in_len, char *mod, int mod_len, char *exp, int exp_len)
enum _RDP_VERSION RDP_VERSION
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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
int const JOCTET unsigned int datalen
#define memcpy(s1, s2, n)
#define sprintf(buf, format,...)
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
static rfbScreenInfoPtr server
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out