Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

secure.cpp File Reference

#include "rdesktop.h"
#include <openssl/rc4.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/bn.h>

Include dependency graph for secure.cpp:

Go to the source code of this file.

Functions

void sec_hash_48 (uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt)
void sec_hash_16 (uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2)
static void sec_make_40bit (uint8 *key)
static void sec_generate_keys (uint8 *client_key, uint8 *server_key, int rc4_key_size)
void buf_out_uint32 (uint8 *buffer, uint32 value)
void sec_sign (uint8 *signature, int siglen, uint8 *session_key, int keylen, uint8 *data, int datalen)
static void sec_update (uint8 *key, uint8 *update_key)
static void sec_encrypt (uint8 *data, int length)
static void sec_decrypt (uint8 *data, int length)
static void reverse (uint8 *p, int len)
static void sec_rsa_encrypt (uint8 *out, uint8 *in, int len, uint8 *modulus, uint8 *exponent)
STREAM sec_init (uint32 flags, int maxlen)
void sec_send (STREAM s, uint32 flags)
static void sec_establish_key (void)
static void sec_out_mcs_data (STREAM s)
static BOOL sec_parse_public_key (STREAM s, uint8 **modulus, uint8 **exponent)
static BOOL sec_parse_crypt_info (STREAM s, uint32 *rc4_key_size, uint8 **server_random, uint8 **modulus, uint8 **exponent)
static void sec_process_crypt_info (STREAM s)
static void sec_process_mcs_data (STREAM s)
STREAM sec_recv (void)
BOOL sec_connect (char *server)
void sec_disconnect (void)

Variables

char hostname [16]
int g_width
int g_height
int keylayout
BOOL encryption
BOOL licence_issued
int server_bpp
static int rc4_key_len
static RC4_KEY rc4_decrypt_key
static RC4_KEY rc4_encrypt_key
static uint8 sec_sign_key [16]
static uint8 sec_decrypt_key [16]
static uint8 sec_encrypt_key [16]
static uint8 sec_decrypt_update_key [16]
static uint8 sec_encrypt_update_key [16]
static uint8 sec_crypted_random [SEC_MODULUS_SIZE]
static uint8 pad_54 [40]
static uint8 pad_92 [48]


Function Documentation

void buf_out_uint32 uint8 buffer,
uint32  value
 

Definition at line 173 of file secure.cpp.

Referenced by licence_generate_hwid(), and sec_sign().

static void reverse uint8 p,
int  len
[static]
 

Definition at line 272 of file secure.cpp.

References i.

Referenced by sec_rsa_encrypt().

BOOL sec_connect char *  server  ) 
 

Definition at line 634 of file secure.cpp.

References stream::data, encryption, False, mcs_connect(), stream::p, sec_establish_key(), sec_out_mcs_data(), sec_process_mcs_data(), stream::size, True, xfree(), and xmalloc().

Referenced by rdp_connect().

static void sec_decrypt uint8 data,
int  length
[static]
 

Definition at line 256 of file secure.cpp.

References rc4_decrypt_key, rc4_key_len, sec_decrypt_key, sec_decrypt_update_key, and sec_update().

Referenced by sec_recv().

void sec_disconnect void   ) 
 

Definition at line 655 of file secure.cpp.

References mcs_disconnect().

Referenced by rdp_disconnect().

static void sec_encrypt uint8 data,
int  length
[static]
 

Definition at line 239 of file secure.cpp.

References rc4_encrypt_key, rc4_key_len, sec_encrypt_key, sec_encrypt_update_key, and sec_update().

Referenced by sec_send().

static void sec_establish_key void   )  [static]
 

Definition at line 367 of file secure.cpp.

References flags, out_uint32_le, out_uint8p, out_uint8s, s, s_mark_end, SEC_CLIENT_RANDOM, sec_crypted_random, sec_init(), SEC_MODULUS_SIZE, SEC_PADDING_SIZE, and sec_send().

Referenced by sec_connect().

static void sec_generate_keys uint8 client_key,
uint8 server_key,
int  rc4_key_size
[static]
 

Definition at line 113 of file secure.cpp.

References DEBUG, input, rc4_decrypt_key, rc4_encrypt_key, rc4_key_len, sec_decrypt_key, sec_decrypt_update_key, sec_encrypt_key, sec_encrypt_update_key, sec_hash_16(), sec_hash_48(), sec_make_40bit(), and sec_sign_key.

Referenced by sec_process_crypt_info().

void sec_hash_16 uint8 out,
uint8 in,
uint8 salt1,
uint8 salt2
 

Definition at line 91 of file secure.cpp.

References md5(), MD5_Final(), MD5_Init(), and MD5_Update().

Referenced by licence_generate_keys(), and sec_generate_keys().

void sec_hash_48 uint8 out,
uint8 in,
uint8 salt1,
uint8 salt2,
uint8  salt
 

Definition at line 60 of file secure.cpp.

References i, md5(), MD5_Final(), MD5_Init(), and MD5_Update().

Referenced by licence_generate_keys(), and sec_generate_keys().

STREAM sec_init uint32  flags,
int  maxlen
 

Definition at line 323 of file secure.cpp.

References licence_issued, mcs_init(), s, s_push_layer, SEC_ENCRYPT, and stream::sec_hdr.

Referenced by licence_present(), licence_send_authresp(), licence_send_request(), rdp_init(), rdp_init_data(), rdp_send_logon_info(), and sec_establish_key().

static void sec_make_40bit uint8 key  )  [static]
 

Definition at line 104 of file secure.cpp.

Referenced by sec_generate_keys(), and sec_update().

static void sec_out_mcs_data STREAM  s  )  [static]
 

Definition at line 385 of file secure.cpp.

References encryption, g_height, g_width, hostname, keylayout, out_uint16, out_uint16_be, out_uint16_le, out_uint32, out_uint32_le, out_uint8, out_uint8s, rdp_out_unistr(), s_mark_end, SEC_TAG_CLI_CRYPT, SEC_TAG_CLI_INFO, and server_bpp.

Referenced by sec_connect().

static BOOL sec_parse_crypt_info STREAM  s,
uint32 rc4_key_size,
uint8 **  server_random,
uint8 **  modulus,
uint8 **  exponent
[static]
 

Definition at line 483 of file secure.cpp.

References stream::end, end, error(), False, in_uint16_le, in_uint32_le, in_uint8p, in_uint8s, stream::p, s_check_end, sec_parse_public_key(), SEC_RANDOM_SIZE, SEC_TAG_KEYSIG, SEC_TAG_PUBKEY, and unimpl().

Referenced by sec_process_crypt_info().

static BOOL sec_parse_public_key STREAM  s,
uint8 **  modulus,
uint8 **  exponent
[static]
 

Definition at line 455 of file secure.cpp.

References error(), False, in_uint32_le, in_uint8p, in_uint8s, s_check, SEC_EXPONENT_SIZE, SEC_MODULUS_SIZE, SEC_PADDING_SIZE, and SEC_RSA_MAGIC.

Referenced by sec_parse_crypt_info().

static void sec_process_crypt_info STREAM  s  )  [static]
 

Definition at line 544 of file secure.cpp.

References generate_random(), sec_crypted_random, sec_generate_keys(), sec_parse_crypt_info(), SEC_RANDOM_SIZE, and sec_rsa_encrypt().

Referenced by sec_process_mcs_data().

static void sec_process_mcs_data STREAM  s  )  [static]
 

Definition at line 561 of file secure.cpp.

References in_uint16_le, in_uint8, in_uint8s, len, sec_process_crypt_info(), SEC_TAG_SRV_3, SEC_TAG_SRV_CRYPT, SEC_TAG_SRV_INFO, and unimpl().

Referenced by sec_connect().

STREAM sec_recv void   ) 
 

Definition at line 602 of file secure.cpp.

References encryption, in_uint32_le, in_uint8s, licence_issued, licence_process(), mcs_recv(), NULL, s, sec_decrypt(), SEC_ENCRYPT, and SEC_LICENCE_NEG.

Referenced by rdp_recv().

static void sec_rsa_encrypt uint8 out,
uint8 in,
int  len,
uint8 modulus,
uint8 exponent
[static]
 

Definition at line 287 of file secure.cpp.

References mod, reverse(), SEC_EXPONENT_SIZE, SEC_MODULUS_SIZE, Opie::MM::x, and Opie::MM::y.

Referenced by sec_process_crypt_info().

void sec_send STREAM  s,
uint32  flags
 

Definition at line 340 of file secure.cpp.

References datalen, DEBUG, hexdump(), licence_issued, mcs_send(), out_uint32_le, rc4_key_len, s_pop_layer, sec_encrypt(), SEC_ENCRYPT, stream::sec_hdr, sec_sign(), and sec_sign_key.

Referenced by licence_present(), licence_send_authresp(), licence_send_request(), rdp_send(), rdp_send_data(), rdp_send_logon_info(), and sec_establish_key().

void sec_sign uint8 signature,
int  siglen,
uint8 session_key,
int  keylen,
uint8 data,
int  datalen
 

Definition at line 183 of file secure.cpp.

References buf_out_uint32(), md5(), MD5_Final(), MD5_Init(), MD5_Update(), pad_54, and pad_92.

Referenced by licence_process_authreq(), licence_process_demand(), and sec_send().

static void sec_update uint8 key,
uint8 update_key
[static]
 

Definition at line 211 of file secure.cpp.

References md5(), MD5_Final(), MD5_Init(), MD5_Update(), pad_54, pad_92, rc4_key_len, and sec_make_40bit().

Referenced by sec_decrypt(), and sec_encrypt().


Variable Documentation

BOOL encryption
 

Definition at line 62 of file rdesktop.cpp.

Referenced by rdp_init(), rdp_init_data(), rdp_send(), rdp_send_data(), rdp_send_logon_info(), sec_connect(), sec_out_mcs_data(), and sec_recv().

int g_height
 

Definition at line 55 of file rdesktop.cpp.

int g_width
 

Definition at line 53 of file rdesktop.cpp.

char hostname[16]
 

Definition at line 50 of file rdesktop.cpp.

int keylayout
 

Definition at line 52 of file rdesktop.cpp.

Referenced by sec_out_mcs_data().

BOOL licence_issued
 

Definition at line 35 of file licence.cpp.

Referenced by licence_process_issue(), sec_init(), sec_recv(), and sec_send().

uint8 pad_54[40] [static]
 

Initial value:

 {
        54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
        54, 54, 54,
        54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
        54, 54, 54
}

Definition at line 157 of file secure.cpp.

Referenced by sec_sign(), and sec_update().

uint8 pad_92[48] [static]
 

Initial value:

 {
        92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
        92, 92, 92, 92, 92, 92, 92,
        92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
        92, 92, 92, 92, 92, 92, 92
}

Definition at line 164 of file secure.cpp.

Referenced by sec_sign(), and sec_update().

RC4_KEY rc4_decrypt_key [static]
 

Definition at line 44 of file secure.cpp.

Referenced by sec_decrypt(), and sec_generate_keys().

RC4_KEY rc4_encrypt_key [static]
 

Definition at line 45 of file secure.cpp.

Referenced by sec_encrypt(), and sec_generate_keys().

int rc4_key_len [static]
 

Definition at line 43 of file secure.cpp.

Referenced by sec_decrypt(), sec_encrypt(), sec_generate_keys(), sec_send(), and sec_update().

uint8 sec_crypted_random[SEC_MODULUS_SIZE] [static]
 

Definition at line 52 of file secure.cpp.

Referenced by sec_establish_key(), and sec_process_crypt_info().

uint8 sec_decrypt_key[16] [static]
 

Definition at line 48 of file secure.cpp.

Referenced by sec_decrypt(), and sec_generate_keys().

uint8 sec_decrypt_update_key[16] [static]
 

Definition at line 50 of file secure.cpp.

Referenced by sec_decrypt(), and sec_generate_keys().

uint8 sec_encrypt_key[16] [static]
 

Definition at line 49 of file secure.cpp.

Referenced by sec_encrypt(), and sec_generate_keys().

uint8 sec_encrypt_update_key[16] [static]
 

Definition at line 51 of file secure.cpp.

Referenced by sec_encrypt(), and sec_generate_keys().

uint8 sec_sign_key[16] [static]
 

Definition at line 47 of file secure.cpp.

Referenced by sec_generate_keys(), and sec_send().

int server_bpp
 

Definition at line 57 of file rdesktop.cpp.


Generated on Sat Nov 5 17:04:15 2005 for OPIE by  doxygen 1.4.2