FreeRDP
rdstls.c File Reference
#include <freerdp/config.h>
#include "settings.h"
#include <freerdp/log.h>
#include <freerdp/error.h>
#include <freerdp/settings.h>
#include <winpr/assert.h>
#include <winpr/stream.h>
#include <winpr/wlog.h>
#include "rdstls.h"
#include "transport.h"
#include "utils.h"

Macros

#define RDSTLS_VERSION_1   0x01
 
#define RDSTLS_TYPE_CAPABILITIES   0x01
 
#define RDSTLS_TYPE_AUTHREQ   0x02
 
#define RDSTLS_TYPE_AUTHRSP   0x04
 
#define RDSTLS_DATA_CAPABILITIES   0x01
 
#define RDSTLS_DATA_PASSWORD_CREDS   0x01
 
#define RDSTLS_DATA_AUTORECONNECT_COOKIE   0x02
 
#define RDSTLS_DATA_RESULT_CODE   0x01
 
#define rdstls_check_state_requirements(rdstls, expected)    rdstls_check_state_requirements_((rdstls), (expected), __FILE__, __func__, __LINE__)
 

Enumerations

enum  RDSTLS_STATE {
  RDSTLS_STATE_INITIAL , RDSTLS_STATE_CAPABILITIES , RDSTLS_STATE_AUTH_REQ , RDSTLS_STATE_AUTH_RSP ,
  RDSTLS_STATE_FINAL
}
 

Functions

rdpRdstls * rdstls_new (rdpContext *context, rdpTransport *transport)
 
void rdstls_free (rdpRdstls *rdstls)
 
static const char * rdstls_get_state_str (RDSTLS_STATE state)
 
static RDSTLS_STATE rdstls_get_state (rdpRdstls *rdstls)
 
static BOOL check_transition (wLog *log, RDSTLS_STATE current, RDSTLS_STATE expected, RDSTLS_STATE requested)
 
static BOOL rdstls_set_state (rdpRdstls *rdstls, RDSTLS_STATE state)
 
static BOOL rdstls_write_capabilities (rdpRdstls *rdstls, wStream *s)
 
static SSIZE_T rdstls_write_string (wStream *s, const char *str)
 
static BOOL rdstls_write_data (wStream *s, UINT32 length, const BYTE *data)
 
static BOOL rdstls_write_authentication_request_with_password (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_write_authentication_request_with_cookie (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_write_authentication_response (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_process_capabilities (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_read_unicode_string (wLog *log, wStream *s, char **str)
 
static BOOL rdstls_read_data (wLog *log, wStream *s, UINT16 *pLength, const BYTE **pData)
 
static BOOL rdstls_cmp_data (wLog *log, const char *field, const BYTE *serverData, const UINT32 serverDataLength, const BYTE *clientData, const UINT16 clientDataLength)
 
static BOOL rdstls_cmp_str (wLog *log, const char *field, const char *serverStr, const char *clientStr)
 
static BOOL rdstls_process_authentication_request_with_password (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_process_authentication_request_with_cookie (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_process_authentication_request (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_process_authentication_response (rdpRdstls *rdstls, wStream *s)
 
static BOOL rdstls_send (rdpTransport *transport, wStream *s, void *extra)
 
static int rdstls_recv (rdpTransport *transport, wStream *s, void *extra)
 
static BOOL rdstls_check_state_requirements_ (rdpRdstls *rdstls, RDSTLS_STATE expected, const char *file, const char *fkt, size_t line)
 
static BOOL rdstls_send_capabilities (rdpRdstls *rdstls)
 
static BOOL rdstls_recv_authentication_request (rdpRdstls *rdstls)
 
static BOOL rdstls_send_authentication_response (rdpRdstls *rdstls)
 
static BOOL rdstls_recv_capabilities (rdpRdstls *rdstls)
 
static BOOL rdstls_send_authentication_request (rdpRdstls *rdstls)
 
static BOOL rdstls_recv_authentication_response (rdpRdstls *rdstls)
 
static int rdstls_server_authenticate (rdpRdstls *rdstls)
 
static int rdstls_client_authenticate (rdpRdstls *rdstls)
 
int rdstls_authenticate (rdpRdstls *rdstls)
 
static SSIZE_T rdstls_parse_pdu_data_type (wLog *log, UINT16 dataType, wStream *s)
 
SSIZE_T rdstls_parse_pdu (wLog *log, wStream *stream)
 

Macro Definition Documentation

◆ rdstls_check_state_requirements

#define rdstls_check_state_requirements (   rdstls,
  expected 
)     rdstls_check_state_requirements_((rdstls), (expected), __FILE__, __func__, __LINE__)

◆ RDSTLS_DATA_AUTORECONNECT_COOKIE

#define RDSTLS_DATA_AUTORECONNECT_COOKIE   0x02

◆ RDSTLS_DATA_CAPABILITIES

#define RDSTLS_DATA_CAPABILITIES   0x01

◆ RDSTLS_DATA_PASSWORD_CREDS

#define RDSTLS_DATA_PASSWORD_CREDS   0x01

◆ RDSTLS_DATA_RESULT_CODE

#define RDSTLS_DATA_RESULT_CODE   0x01

◆ RDSTLS_TYPE_AUTHREQ

#define RDSTLS_TYPE_AUTHREQ   0x02

◆ RDSTLS_TYPE_AUTHRSP

#define RDSTLS_TYPE_AUTHRSP   0x04

◆ RDSTLS_TYPE_CAPABILITIES

#define RDSTLS_TYPE_CAPABILITIES   0x01

◆ RDSTLS_VERSION_1

#define RDSTLS_VERSION_1   0x01

FreeRDP: A Remote Desktop Protocol Implementation RDSTLS Security protocol

Copyright 2023 Joan Torres joan..nosp@m.torr.nosp@m.es@su.nosp@m.se.c.nosp@m.om

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.

Enumeration Type Documentation

◆ RDSTLS_STATE

Enumerator
RDSTLS_STATE_INITIAL 
RDSTLS_STATE_CAPABILITIES 
RDSTLS_STATE_AUTH_REQ 
RDSTLS_STATE_AUTH_RSP 
RDSTLS_STATE_FINAL 

Function Documentation

◆ check_transition()

static BOOL check_transition ( wLog *  log,
RDSTLS_STATE  current,
RDSTLS_STATE  expected,
RDSTLS_STATE  requested 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_authenticate()

int rdstls_authenticate ( rdpRdstls *  rdstls)

Authenticate using RDSTLS.

Parameters
rdstlsThe RDSTLS instance to use
Returns
1 if authentication is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_check_state_requirements_()

static BOOL rdstls_check_state_requirements_ ( rdpRdstls *  rdstls,
RDSTLS_STATE  expected,
const char *  file,
const char *  fkt,
size_t  line 
)
static
Here is the call graph for this function:

◆ rdstls_client_authenticate()

static int rdstls_client_authenticate ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_cmp_data()

static BOOL rdstls_cmp_data ( wLog *  log,
const char *  field,
const BYTE serverData,
const UINT32  serverDataLength,
const BYTE clientData,
const UINT16  clientDataLength 
)
static
Here is the caller graph for this function:

◆ rdstls_cmp_str()

static BOOL rdstls_cmp_str ( wLog *  log,
const char *  field,
const char *  serverStr,
const char *  clientStr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_free()

void rdstls_free ( rdpRdstls *  rdstls)

Free RDSTLS state machine.

Parameters
rdstlsThe RDSTLS instance to free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_get_state()

static RDSTLS_STATE rdstls_get_state ( rdpRdstls *  rdstls)
static
Here is the caller graph for this function:

◆ rdstls_get_state_str()

static const char* rdstls_get_state_str ( RDSTLS_STATE  state)
static
Here is the caller graph for this function:

◆ rdstls_new()

rdpRdstls* rdstls_new ( rdpContext *  context,
rdpTransport *  transport 
)

Create new RDSTLS state machine.

Parameters
contextA pointer to the rdp context to use
Returns
new RDSTLS state machine.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_parse_pdu()

SSIZE_T rdstls_parse_pdu ( wLog *  log,
wStream stream 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_parse_pdu_data_type()

static SSIZE_T rdstls_parse_pdu_data_type ( wLog *  log,
UINT16  dataType,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_process_authentication_request()

static BOOL rdstls_process_authentication_request ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_process_authentication_request_with_cookie()

static BOOL rdstls_process_authentication_request_with_cookie ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the caller graph for this function:

◆ rdstls_process_authentication_request_with_password()

static BOOL rdstls_process_authentication_request_with_password ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_process_authentication_response()

static BOOL rdstls_process_authentication_response ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_process_capabilities()

static BOOL rdstls_process_capabilities ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the caller graph for this function:

◆ rdstls_read_data()

static BOOL rdstls_read_data ( wLog *  log,
wStream s,
UINT16 pLength,
const BYTE **  pData 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_read_unicode_string()

static BOOL rdstls_read_unicode_string ( wLog *  log,
wStream s,
char **  str 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_recv()

static int rdstls_recv ( rdpTransport *  transport,
wStream s,
void *  extra 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_recv_authentication_request()

static BOOL rdstls_recv_authentication_request ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_recv_authentication_response()

static BOOL rdstls_recv_authentication_response ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_recv_capabilities()

static BOOL rdstls_recv_capabilities ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_send()

static BOOL rdstls_send ( rdpTransport *  transport,
wStream s,
void *  extra 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_send_authentication_request()

static BOOL rdstls_send_authentication_request ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_send_authentication_response()

static BOOL rdstls_send_authentication_response ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_send_capabilities()

static BOOL rdstls_send_capabilities ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_server_authenticate()

static int rdstls_server_authenticate ( rdpRdstls *  rdstls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_set_state()

static BOOL rdstls_set_state ( rdpRdstls *  rdstls,
RDSTLS_STATE  state 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_write_authentication_request_with_cookie()

static BOOL rdstls_write_authentication_request_with_cookie ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the caller graph for this function:

◆ rdstls_write_authentication_request_with_password()

static BOOL rdstls_write_authentication_request_with_password ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_write_authentication_response()

static BOOL rdstls_write_authentication_response ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_write_capabilities()

static BOOL rdstls_write_capabilities ( rdpRdstls *  rdstls,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_write_data()

static BOOL rdstls_write_data ( wStream s,
UINT32  length,
const BYTE data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rdstls_write_string()

static SSIZE_T rdstls_write_string ( wStream s,
const char *  str 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: