FreeRDP
assistance.c File Reference
#include <freerdp/config.h>
#include <errno.h>
#include <winpr/wtypes.h>
#include <winpr/collections.h>
#include <winpr/string.h>
#include <winpr/crt.h>
#include <winpr/crypto.h>
#include <winpr/print.h>
#include <winpr/windows.h>
#include <winpr/ssl.h>
#include <winpr/file.h>
#include <freerdp/log.h>
#include <freerdp/client/file.h>
#include <freerdp/client/cmdline.h>
#include <freerdp/assistance.h>
#include "../core/settings.h"

Macros

#define TAG   FREERDP_TAG("common")
 

Functions

static const char * strrstr (const char *haystack, size_t len, const char *needle)
 
static BOOL update_option (char **opt, const char *val, size_t len)
 
static BOOL update_name (rdpAssistanceFile *file, const char *name)
 
static BOOL update_password (rdpAssistanceFile *file, const char *password)
 
static BOOL update_connectionstring2_nocopy (rdpAssistanceFile *file, char *str)
 
static BOOL update_connectionstring2 (rdpAssistanceFile *file, const char *str, size_t len)
 
static BOOL update_connectionstring2_wchar (rdpAssistanceFile *file, const WCHAR *str, size_t len)
 
static BOOL freerdp_assistance_crypt_derive_key_sha1 (BYTE *hash, size_t hashLength, BYTE *key, size_t keyLength)
 
static BOOL append_address_to_list (wArrayList *MachineAddresses, const char *str, size_t len)
 
static BOOL append_address (rdpAssistanceFile *file, const char *host, const char *port)
 
static BOOL freerdp_assistance_parse_address_list (rdpAssistanceFile *file, char *list)
 
static BOOL freerdp_assistance_parse_connection_string1 (rdpAssistanceFile *file)
 
static BOOL freerdp_assistance_parse_attr (const char **opt, size_t *plength, const char *key, const char *tag)
 
static BOOL freerdp_assistance_parse_attr_str (char **opt, const char *key, const char *tag)
 
static BOOL freerdp_assistance_parse_attr_bool (BOOL *opt, const char *key, const char *tag)
 
static BOOL freerdp_assistance_parse_attr_uint32 (UINT32 *opt, const char *key, const char *tag)
 
static char * freerdp_assistance_contains_element (char *input, size_t ilen, const char *key, size_t *plen, char **pdata, size_t *pdlen)
 
static BOOL freerdp_assistance_consume_input_and_get_element (char *input, const char *key, char **element, size_t *elen)
 this function returns a XML element identified by key The input string will be manipulated, so that the element found is '\0' terminated. More...
 
static BOOL freerdp_assistance_get_element (char *input, size_t ilen, const char *key, char **element, size_t *elen)
 
static BOOL freerdp_assistance_parse_all_elements_of (rdpAssistanceFile *file, char *data, size_t len, const char *key, BOOL(*fkt)(rdpAssistanceFile *file, char *data, size_t len))
 
static BOOL freerdp_assistance_parse_all_elements_of_l (rdpAssistanceFile *file, char *data, size_t len)
 
static BOOL freerdp_assistance_parse_all_elements_of_t (rdpAssistanceFile *file, char *data, size_t len)
 
static BOOL freerdp_assistance_parse_all_elements_of_c (rdpAssistanceFile *file, char *data, size_t len)
 
static BOOL freerdp_assistance_parse_find_elements_of_c (rdpAssistanceFile *file, char *data, size_t len)
 
static BOOL freerdp_assistance_parse_connection_string2 (rdpAssistanceFile *file)
 
char * freerdp_assistance_construct_expert_blob (const char *name, const char *pass)
 
char * freerdp_assistance_generate_pass_stub (DWORD flags)
 
BYTEfreerdp_assistance_encrypt_pass_stub (const char *password, const char *passStub, size_t *pEncryptedSize)
 
static BOOL freerdp_assistance_decrypt2 (rdpAssistanceFile *file)
 
BYTEfreerdp_assistance_hex_string_to_bin (const void *raw, size_t *size)
 
char * freerdp_assistance_bin_to_hex_string (const void *raw, size_t size)
 
static int freerdp_assistance_parse_uploadinfo (rdpAssistanceFile *file, char *uploadinfo, size_t uploadinfosize)
 
static int freerdp_assistance_parse_file_buffer_int (rdpAssistanceFile *file, char *buffer, size_t size, const char *password)
 
int freerdp_assistance_parse_file_buffer (rdpAssistanceFile *file, const char *cbuffer, size_t size, const char *password)
 
int freerdp_assistance_parse_file (rdpAssistanceFile *file, const char *name, const char *password)
 
BOOL freerdp_assistance_populate_settings_from_assistance_file (rdpAssistanceFile *file, rdpSettings *settings)
 
static BOOL setup_string (wArrayList *list)
 
rdpAssistanceFile * freerdp_assistance_file_new (void)
 
void freerdp_assistance_file_free (rdpAssistanceFile *file)
 
void freerdp_assistance_print_file (rdpAssistanceFile *file, wLog *log, DWORD level)
 
BOOL freerdp_assistance_get_encrypted_pass_stub (rdpAssistanceFile *file, const char **pwd, size_t *size)
 
int freerdp_assistance_set_connection_string2 (rdpAssistanceFile *file, const char *string, const char *password)
 

Macro Definition Documentation

◆ TAG

#define TAG   FREERDP_TAG("common")

FreeRDP: A Remote Desktop Protocol Implementation Remote Assistance

Copyright 2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ append_address()

static BOOL append_address ( rdpAssistanceFile *  file,
const char *  host,
const char *  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_address_to_list()

static BOOL append_address_to_list ( wArrayList *  MachineAddresses,
const char *  str,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_bin_to_hex_string()

char* freerdp_assistance_bin_to_hex_string ( const void *  raw,
size_t  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_construct_expert_blob()

char* freerdp_assistance_construct_expert_blob ( const char *  name,
const char *  pass 
)
Here is the caller graph for this function:

◆ freerdp_assistance_consume_input_and_get_element()

static BOOL freerdp_assistance_consume_input_and_get_element ( char *  input,
const char *  key,
char **  element,
size_t *  elen 
)
static

this function returns a XML element identified by key The input string will be manipulated, so that the element found is '\0' terminated.

!

This function can not find multiple elements on the same level as the input string is changed!

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_contains_element()

static char* freerdp_assistance_contains_element ( char *  input,
size_t  ilen,
const char *  key,
size_t *  plen,
char **  pdata,
size_t *  pdlen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_crypt_derive_key_sha1()

static BOOL freerdp_assistance_crypt_derive_key_sha1 ( BYTE hash,
size_t  hashLength,
BYTE key,
size_t  keyLength 
)
static

Password encryption in establishing a remote assistance session of type 1: http://blogs.msdn.com/b/openspecification/archive/2011/10/31/password-encryption-in-establishing-a-remote-assistance-session-of-type-1.aspx

Creation of PassStub for the Remote Assistance Ticket: http://social.msdn.microsoft.com/Forums/en-US/6316c3f4-ea09-4343-a4a1-9cca46d70d28/creation-of-passstub-for-the-remote-assistance-ticket?forum=os_windowsprotocols CryptDeriveKey Function: http://msdn.microsoft.com/en-us/library/windows/desktop/aa379916/

Let n be the required derived key length, in bytes. The derived key is the first n bytes of the hash value after the hash computation has been completed by CryptDeriveKey. If the hash is not a member of the SHA-2 family and the required key is for either 3DES or AES, the key is derived as follows:

Form a 64-byte buffer by repeating the constant 0x36 64 times. Let k be the length of the hash value that is represented by the input parameter hBaseData. Set the first k bytes of the buffer to the result of an XOR operation of the first k bytes of the buffer with the hash value that is represented by the input parameter hBaseData.

Form a 64-byte buffer by repeating the constant 0x5C 64 times. Set the first k bytes of the buffer to the result of an XOR operation of the first k bytes of the buffer with the hash value that is represented by the input parameter hBaseData.

Hash the result of step 1 by using the same hash algorithm as that used to compute the hash value that is represented by the hBaseData parameter.

Hash the result of step 2 by using the same hash algorithm as that used to compute the hash value that is represented by the hBaseData parameter.

Concatenate the result of step 3 with the result of step 4. Use the first n bytes of the result of step 5 as the derived key.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_decrypt2()

static BOOL freerdp_assistance_decrypt2 ( rdpAssistanceFile *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_encrypt_pass_stub()

BYTE* freerdp_assistance_encrypt_pass_stub ( const char *  password,
const char *  passStub,
size_t *  pEncryptedSize 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_file_free()

void freerdp_assistance_file_free ( rdpAssistanceFile *  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_file_new()

rdpAssistanceFile* freerdp_assistance_file_new ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_generate_pass_stub()

char* freerdp_assistance_generate_pass_stub ( DWORD  flags)

PassStub generation:

Characters 0 and 5-13 are from the set A-Z a-z 0-9 * _ Character 1 is from the set !#$&^*()-+= Character 2 is from the set 0-9 Character 3 is from the set A-Z Character 4 is from the set a-z

Example: WB^6HsrIaFmEpi

Here is the call graph for this function:

◆ freerdp_assistance_get_element()

static BOOL freerdp_assistance_get_element ( char *  input,
size_t  ilen,
const char *  key,
char **  element,
size_t *  elen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_get_encrypted_pass_stub()

BOOL freerdp_assistance_get_encrypted_pass_stub ( rdpAssistanceFile *  file,
const char **  pwd,
size_t *  size 
)
Here is the caller graph for this function:

◆ freerdp_assistance_hex_string_to_bin()

BYTE* freerdp_assistance_hex_string_to_bin ( const void *  raw,
size_t *  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_address_list()

static BOOL freerdp_assistance_parse_address_list ( rdpAssistanceFile *  file,
char *  list 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_all_elements_of()

static BOOL freerdp_assistance_parse_all_elements_of ( rdpAssistanceFile *  file,
char *  data,
size_t  len,
const char *  key,
BOOL(*)(rdpAssistanceFile *file, char *data, size_t len fkt 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_all_elements_of_c()

static BOOL freerdp_assistance_parse_all_elements_of_c ( rdpAssistanceFile *  file,
char *  data,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_all_elements_of_l()

static BOOL freerdp_assistance_parse_all_elements_of_l ( rdpAssistanceFile *  file,
char *  data,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_all_elements_of_t()

static BOOL freerdp_assistance_parse_all_elements_of_t ( rdpAssistanceFile *  file,
char *  data,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_attr()

static BOOL freerdp_assistance_parse_attr ( const char **  opt,
size_t *  plength,
const char *  key,
const char *  tag 
)
static

Decrypted Connection String 2:

<E> <T ID="1" SID="0"> <L P="49228" N="fe80::1032:53d9:5a01:909b%3"> <L P="49229" N="fe80::3d8f:9b2d:6b4e:6aa%6"> <L P="49230" N="192.168.1.200"> <L P="49231" N="169.254.6.170"> </T> </E>

Here is the caller graph for this function:

◆ freerdp_assistance_parse_attr_bool()

static BOOL freerdp_assistance_parse_attr_bool ( BOOL *  opt,
const char *  key,
const char *  tag 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_attr_str()

static BOOL freerdp_assistance_parse_attr_str ( char **  opt,
const char *  key,
const char *  tag 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_attr_uint32()

static BOOL freerdp_assistance_parse_attr_uint32 ( UINT32 *  opt,
const char *  key,
const char *  tag 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_connection_string1()

static BOOL freerdp_assistance_parse_connection_string1 ( rdpAssistanceFile *  file)
static

<ProtocolVersion>,<protocolType>,<machineAddressList>,<assistantAccountPwd>, <RASessionID>,<RASessionName>,<RASessionPwd>,<protocolSpecificParms>

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_connection_string2()

static BOOL freerdp_assistance_parse_connection_string2 ( rdpAssistanceFile *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_file()

int freerdp_assistance_parse_file ( rdpAssistanceFile *  file,
const char *  name,
const char *  password 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_file_buffer()

int freerdp_assistance_parse_file_buffer ( rdpAssistanceFile *  file,
const char *  cbuffer,
size_t  size,
const char *  password 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_file_buffer_int()

static int freerdp_assistance_parse_file_buffer_int ( rdpAssistanceFile *  file,
char *  buffer,
size_t  size,
const char *  password 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_find_elements_of_c()

static BOOL freerdp_assistance_parse_find_elements_of_c ( rdpAssistanceFile *  file,
char *  data,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_parse_uploadinfo()

static int freerdp_assistance_parse_uploadinfo ( rdpAssistanceFile *  file,
char *  uploadinfo,
size_t  uploadinfosize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_populate_settings_from_assistance_file()

BOOL freerdp_assistance_populate_settings_from_assistance_file ( rdpAssistanceFile *  file,
rdpSettings *  settings 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_print_file()

void freerdp_assistance_print_file ( rdpAssistanceFile *  file,
wLog *  log,
DWORD  level 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_assistance_set_connection_string2()

int freerdp_assistance_set_connection_string2 ( rdpAssistanceFile *  file,
const char *  string,
const char *  password 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_string()

static BOOL setup_string ( wArrayList *  list)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ strrstr()

static const char* strrstr ( const char *  haystack,
size_t  len,
const char *  needle 
)
static
Here is the caller graph for this function:

◆ update_connectionstring2()

static BOOL update_connectionstring2 ( rdpAssistanceFile *  file,
const char *  str,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_connectionstring2_nocopy()

static BOOL update_connectionstring2_nocopy ( rdpAssistanceFile *  file,
char *  str 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_connectionstring2_wchar()

static BOOL update_connectionstring2_wchar ( rdpAssistanceFile *  file,
const WCHAR *  str,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_name()

static BOOL update_name ( rdpAssistanceFile *  file,
const char *  name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_option()

static BOOL update_option ( char **  opt,
const char *  val,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_password()

static BOOL update_password ( rdpAssistanceFile *  file,
const char *  password 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: