2011-07-05 01:05:58 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-05 01:05:58 +04:00
|
|
|
* T.124 Generic Conference Control (GCC)
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
* Copyright 2014 Norbert Federa <norbert.federa@thincast.com>
|
2015-01-13 19:09:36 +03:00
|
|
|
* Copyright 2014 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2011-07-05 01:05:58 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-12-14 22:11:07 +04:00
|
|
|
#include <winpr/crt.h>
|
2011-08-31 12:35:50 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
|
2011-07-05 01:05:58 +04:00
|
|
|
#include "gcc.h"
|
2011-09-05 22:02:52 +04:00
|
|
|
#include "certificate.h"
|
2011-07-05 01:05:58 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
#define TAG FREERDP_TAG("core.gcc")
|
2014-09-12 16:36:29 +04:00
|
|
|
|
2011-07-05 01:05:58 +04:00
|
|
|
/**
|
|
|
|
* T.124 GCC is defined in:
|
|
|
|
*
|
|
|
|
* http://www.itu.int/rec/T-REC-T.124-199802-S/en
|
|
|
|
* ITU-T T.124 (02/98): Generic Conference Control
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ConnectData ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* t124Identifier Key,
|
|
|
|
* connectPDU OCTET_STRING
|
|
|
|
* }
|
|
|
|
*
|
2011-07-05 03:13:01 +04:00
|
|
|
* Key ::= CHOICE
|
|
|
|
* {
|
|
|
|
* object OBJECT_IDENTIFIER,
|
|
|
|
* h221NonStandard H221NonStandardIdentifier
|
|
|
|
* }
|
|
|
|
*
|
2011-07-05 01:05:58 +04:00
|
|
|
* ConnectGCCPDU ::= CHOICE
|
|
|
|
* {
|
|
|
|
* conferenceCreateRequest ConferenceCreateRequest,
|
|
|
|
* conferenceCreateResponse ConferenceCreateResponse,
|
|
|
|
* conferenceQueryRequest ConferenceQueryRequest,
|
|
|
|
* conferenceQueryResponse ConferenceQueryResponse,
|
|
|
|
* conferenceJoinRequest ConferenceJoinRequest,
|
|
|
|
* conferenceJoinResponse ConferenceJoinResponse,
|
|
|
|
* conferenceInviteRequest ConferenceInviteRequest,
|
|
|
|
* conferenceInviteResponse ConferenceInviteResponse,
|
|
|
|
* ...
|
|
|
|
* }
|
2011-07-05 03:13:01 +04:00
|
|
|
*
|
|
|
|
* ConferenceCreateRequest ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* conferenceName ConferenceName,
|
|
|
|
* convenerPassword Password OPTIONAL,
|
|
|
|
* password Password OPTIONAL,
|
|
|
|
* lockedConference BOOLEAN,
|
|
|
|
* listedConference BOOLEAN,
|
|
|
|
* conductibleConference BOOLEAN,
|
|
|
|
* terminationMethod TerminationMethod,
|
|
|
|
* conductorPrivileges SET OF Privilege OPTIONAL,
|
|
|
|
* conductedPrivileges SET OF Privilege OPTIONAL,
|
|
|
|
* nonConductedPrivileges SET OF Privilege OPTIONAL,
|
|
|
|
* conferenceDescription TextString OPTIONAL,
|
|
|
|
* callerIdentifier TextString OPTIONAL,
|
|
|
|
* userData UserData OPTIONAL,
|
|
|
|
* ...,
|
|
|
|
* conferencePriority ConferencePriority OPTIONAL,
|
|
|
|
* conferenceMode ConferenceMode OPTIONAL
|
|
|
|
* }
|
|
|
|
*
|
2011-07-10 01:28:30 +04:00
|
|
|
* ConferenceCreateResponse ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* nodeID UserID,
|
|
|
|
* tag INTEGER,
|
|
|
|
* result ENUMERATED
|
|
|
|
* {
|
|
|
|
* success (0),
|
|
|
|
* userRejected (1),
|
|
|
|
* resourcesNotAvailable (2),
|
|
|
|
* rejectedForSymmetryBreaking (3),
|
|
|
|
* lockedConferenceNotSupported (4)
|
|
|
|
* },
|
|
|
|
* userData UserData OPTIONAL,
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
*
|
2011-07-05 03:13:01 +04:00
|
|
|
* ConferenceName ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* numeric SimpleNumericString
|
|
|
|
* text SimpleTextString OPTIONAL,
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* SimpleNumericString ::= NumericString (SIZE (1..255)) (FROM ("0123456789"))
|
|
|
|
*
|
|
|
|
* UserData ::= SET OF SEQUENCE
|
|
|
|
* {
|
|
|
|
* key Key,
|
|
|
|
* value OCTET_STRING OPTIONAL
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* H221NonStandardIdentifier ::= OCTET STRING (SIZE (4..255))
|
|
|
|
*
|
2011-07-10 01:28:30 +04:00
|
|
|
* UserID ::= DynamicChannelID
|
|
|
|
*
|
|
|
|
* ChannelID ::= INTEGER (1..65535)
|
|
|
|
* StaticChannelID ::= INTEGER (1..1000)
|
|
|
|
* DynamicChannelID ::= INTEGER (1001..65535)
|
|
|
|
*
|
2011-07-05 01:05:58 +04:00
|
|
|
*/
|
|
|
|
|
2011-07-05 03:13:01 +04:00
|
|
|
/*
|
|
|
|
* OID = 0.0.20.124.0.1
|
|
|
|
* { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 }
|
|
|
|
* v.1 of ITU-T Recommendation T.124 (Feb 1998): "Generic Conference Control"
|
|
|
|
*/
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 };
|
2011-07-05 03:13:01 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE h221_cs_key[4] = "Duca";
|
|
|
|
BYTE h221_sc_key[4] = "McDn";
|
2011-07-10 01:28:30 +04:00
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a GCC Conference Create Request.\n
|
|
|
|
* @msdn{cc240836}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_conference_create_request(wStream* s, rdpMcs* mcs)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
|
|
|
BYTE choice;
|
|
|
|
BYTE number;
|
|
|
|
BYTE selection;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* ConnectData */
|
|
|
|
if (!per_read_choice(s, &choice))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
if (!per_read_object_identifier(s, t124_02_98_oid))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* ConnectData::connectPDU (OCTET_STRING) */
|
|
|
|
if (!per_read_length(s, &length))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* ConnectGCCPDU */
|
|
|
|
if (!per_read_choice(s, &choice))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
if (!per_read_selection(s, &selection))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* ConferenceCreateRequest::conferenceName */
|
|
|
|
if (!per_read_numeric_string(s, 1)) /* ConferenceName::numeric */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
if (!per_read_padding(s, 1)) /* padding */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* UserData (SET OF SEQUENCE) */
|
|
|
|
if (!per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
if (!per_read_choice(s, &choice) || choice != 0xC0) /* UserData::value present + select h221NonStandard (1) */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* h221NonStandard */
|
|
|
|
if (!per_read_octet_string(s, h221_cs_key, 4, 4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* userData::value (OCTET_STRING) */
|
|
|
|
if (!per_read_length(s, &length))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < length)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_data_blocks(s, mcs, length))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 05:35:32 +04:00
|
|
|
/**
|
|
|
|
* Write a GCC Conference Create Request.\n
|
|
|
|
* @msdn{cc240836}
|
|
|
|
* @param s stream
|
|
|
|
* @param user_data client data blocks
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_conference_create_request(wStream* s, wStream* userData)
|
2011-07-05 03:13:01 +04:00
|
|
|
{
|
|
|
|
/* ConnectData */
|
|
|
|
per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */
|
|
|
|
per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
|
|
|
|
|
|
|
|
/* ConnectData::connectPDU (OCTET_STRING) */
|
2014-02-14 02:50:38 +04:00
|
|
|
per_write_length(s, Stream_GetPosition(userData) + 14); /* connectPDU length */
|
2011-07-05 03:13:01 +04:00
|
|
|
|
|
|
|
/* ConnectGCCPDU */
|
|
|
|
per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
|
|
|
|
per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */
|
|
|
|
|
|
|
|
/* ConferenceCreateRequest::conferenceName */
|
2012-10-09 11:01:37 +04:00
|
|
|
per_write_numeric_string(s, (BYTE*)"1", 1, 1); /* ConferenceName::numeric */
|
2011-07-05 03:13:01 +04:00
|
|
|
per_write_padding(s, 1); /* padding */
|
|
|
|
|
|
|
|
/* UserData (SET OF SEQUENCE) */
|
|
|
|
per_write_number_of_sets(s, 1); /* one set of UserData */
|
|
|
|
per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */
|
2011-07-05 01:05:58 +04:00
|
|
|
|
2011-07-05 03:13:01 +04:00
|
|
|
/* h221NonStandard */
|
2011-07-10 01:28:30 +04:00
|
|
|
per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
2011-07-05 01:05:58 +04:00
|
|
|
|
2011-07-05 03:13:01 +04:00
|
|
|
/* userData::value (OCTET_STRING) */
|
2016-02-25 22:01:12 +03:00
|
|
|
per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData), 0); /* array of client data blocks */
|
2011-07-05 03:13:01 +04:00
|
|
|
}
|
2011-07-05 06:02:00 +04:00
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_conference_create_response(wStream* s, rdpMcs* mcs)
|
2011-07-10 01:28:30 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 tag;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 nodeID;
|
|
|
|
BYTE result;
|
|
|
|
BYTE choice;
|
|
|
|
BYTE number;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConnectData */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_choice(s, &choice) ||
|
|
|
|
!per_read_object_identifier(s, t124_02_98_oid))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConnectData::connectPDU (OCTET_STRING) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_length(s, &length))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConnectGCCPDU */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_choice(s, &choice))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConferenceCreateResponse::nodeID (UserID) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_integer16(s, &nodeID, 1001))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConferenceCreateResponse::tag (INTEGER) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_integer(s, &tag))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* ConferenceCreateResponse::result (ENUMERATED) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_enumerated(s, &result, MCS_Result_enum_length))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* number of UserData sets */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_number_of_sets(s, &number))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* UserData::value present + select h221NonStandard (1) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_choice(s, &choice))
|
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* h221NonStandard */
|
2011-09-05 22:02:52 +04:00
|
|
|
if (!per_read_octet_string(s, h221_sc_key, 4, 4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-10 01:28:30 +04:00
|
|
|
|
|
|
|
/* userData (OCTET_STRING) */
|
2013-11-29 02:17:21 +04:00
|
|
|
if (!per_read_length(s, &length))
|
|
|
|
return FALSE;
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_data_blocks(s, mcs, length))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_conference_create_response: gcc_read_server_data_blocks failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
void gcc_write_conference_create_response(wStream* s, wStream* userData)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
|
|
|
/* ConnectData */
|
|
|
|
per_write_choice(s, 0);
|
|
|
|
per_write_object_identifier(s, t124_02_98_oid);
|
|
|
|
|
|
|
|
/* ConnectData::connectPDU (OCTET_STRING) */
|
2014-10-22 13:24:36 +04:00
|
|
|
/* This length MUST be ignored by the client according to [MS-RDPBCGR] */
|
2014-09-24 06:04:02 +04:00
|
|
|
per_write_length(s, 0x2A);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
|
|
|
/* ConnectGCCPDU */
|
|
|
|
per_write_choice(s, 0x14);
|
|
|
|
|
|
|
|
/* ConferenceCreateResponse::nodeID (UserID) */
|
|
|
|
per_write_integer16(s, 0x79F3, 1001);
|
|
|
|
|
|
|
|
/* ConferenceCreateResponse::tag (INTEGER) */
|
|
|
|
per_write_integer(s, 1);
|
|
|
|
|
|
|
|
/* ConferenceCreateResponse::result (ENUMERATED) */
|
|
|
|
per_write_enumerated(s, 0, MCS_Result_enum_length);
|
|
|
|
|
|
|
|
/* number of UserData sets */
|
|
|
|
per_write_number_of_sets(s, 1);
|
|
|
|
|
|
|
|
/* UserData::value present + select h221NonStandard (1) */
|
|
|
|
per_write_choice(s, 0xC0);
|
|
|
|
|
|
|
|
/* h221NonStandard */
|
|
|
|
per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
|
|
|
|
|
|
|
/* userData (OCTET_STRING) */
|
2016-02-25 22:01:12 +03:00
|
|
|
per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData), 0); /* array of server data blocks */
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_data_blocks(wStream* s, rdpMcs* mcs, int length)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 type;
|
|
|
|
UINT16 blockLength;
|
2014-01-24 01:00:02 +04:00
|
|
|
int begPos, endPos;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
while (length > 0)
|
|
|
|
{
|
2014-01-24 01:00:02 +04:00
|
|
|
begPos = Stream_GetPosition(s);
|
|
|
|
|
|
|
|
if (!gcc_read_user_data_header(s, &type, &blockLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (blockLength - 4))
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CS_CORE:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_core_data(s, mcs, blockLength - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_SECURITY:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_security_data(s, mcs, blockLength - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_NET:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_network_data(s, mcs, blockLength - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_CLUSTER:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_cluster_data(s, mcs, blockLength - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_MONITOR:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_monitor_data(s, mcs, blockLength - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
case CS_MCS_MSGCHANNEL:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_message_channel_data(s, mcs, blockLength - 4))
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_MONITOR_EX:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_monitor_extended_data(s, mcs, blockLength - 4))
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
2014-11-20 05:00:28 +03:00
|
|
|
case 0xC009:
|
2014-01-24 01:00:02 +04:00
|
|
|
case CS_MULTITRANSPORT:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_client_multitransport_channel_data(s, mcs, blockLength - 4))
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
default:
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "Unknown GCC client data block: 0x%04X", type);
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek(s, blockLength - 4);
|
2011-08-19 13:39:37 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
endPos = Stream_GetPosition(s);
|
|
|
|
|
|
|
|
if (endPos != (begPos + blockLength))
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "Error parsing GCC client data block 0x%04X: Actual Offset: %d Expected Offset: %d",
|
2014-01-24 01:00:02 +04:00
|
|
|
type, endPos, begPos + blockLength);
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
length -= blockLength;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_SetPosition(s, begPos + blockLength);
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_data_blocks(wStream* s, rdpMcs* mcs)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
|
|
|
gcc_write_client_core_data(s, mcs);
|
|
|
|
gcc_write_client_cluster_data(s, mcs);
|
|
|
|
gcc_write_client_security_data(s, mcs);
|
|
|
|
gcc_write_client_network_data(s, mcs);
|
2011-12-18 21:10:56 +04:00
|
|
|
|
|
|
|
/* extended client data supported */
|
|
|
|
|
2012-12-13 23:38:02 +04:00
|
|
|
if (settings->NegotiationFlags & EXTENDED_CLIENT_DATA_SUPPORTED)
|
|
|
|
{
|
2014-03-25 22:39:21 +04:00
|
|
|
if (settings->UseMultimon && !settings->SpanMonitors)
|
2012-12-13 23:38:02 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
gcc_write_client_monitor_data(s, mcs);
|
2015-08-27 09:10:42 +03:00
|
|
|
gcc_write_client_monitor_extended_data(s, mcs);
|
2012-12-13 23:38:02 +04:00
|
|
|
}
|
2014-03-25 22:39:21 +04:00
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
gcc_write_client_message_channel_data(s, mcs);
|
|
|
|
gcc_write_client_multitransport_channel_data(s, mcs);
|
2012-12-13 23:38:02 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-25 22:39:21 +04:00
|
|
|
if (settings->UseMultimon && !settings->SpanMonitors)
|
2012-12-13 23:38:02 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "WARNING: true multi monitor support was not advertised by server!");
|
2012-12-13 23:38:02 +04:00
|
|
|
|
|
|
|
if (settings->ForceMultimon)
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "Sending multi monitor information anyway (may break connectivity!)");
|
2014-02-14 02:50:38 +04:00
|
|
|
gcc_write_client_monitor_data(s, mcs);
|
2015-08-27 09:10:42 +03:00
|
|
|
gcc_write_client_monitor_extended_data(s, mcs);
|
2012-12-13 23:38:02 +04:00
|
|
|
}
|
2012-12-14 01:29:16 +04:00
|
|
|
else
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "Use /multimon:force to force sending multi monitor information");
|
2012-12-14 01:29:16 +04:00
|
|
|
}
|
2012-12-13 23:38:02 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 type;
|
|
|
|
UINT16 offset = 0;
|
|
|
|
UINT16 blockLength;
|
|
|
|
BYTE* holdp;
|
2011-07-10 05:04:57 +04:00
|
|
|
|
|
|
|
while (offset < length)
|
|
|
|
{
|
2013-05-15 20:14:26 +04:00
|
|
|
holdp = Stream_Pointer(s);
|
2011-09-05 22:02:52 +04:00
|
|
|
|
2011-08-22 11:03:58 +04:00
|
|
|
if (!gcc_read_user_data_header(s, &type, &blockLength))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_user_data_header failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-07-10 05:04:57 +04:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SC_CORE:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_core_data(s, mcs))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_core_data failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-07-10 05:04:57 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SC_SECURITY:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_security_data(s, mcs))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_security_data failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-07-10 05:04:57 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SC_NET:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_network_data(s, mcs))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_network_data failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-07-10 05:04:57 +04:00
|
|
|
break;
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
case SC_MCS_MSGCHANNEL:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_message_channel_data(s, mcs))
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_message_channel_data failed");
|
2014-01-24 03:01:31 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SC_MULTITRANSPORT:
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_server_multitransport_channel_data(s, mcs))
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: gcc_read_server_multitransport_channel_data failed");
|
2014-01-24 03:01:31 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-07-10 05:04:57 +04:00
|
|
|
default:
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gcc_read_server_data_blocks: ignoring type=%hu", type);
|
2011-07-10 05:04:57 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset += blockLength;
|
2016-02-25 22:01:12 +03:00
|
|
|
Stream_SetPointer(s, holdp + blockLength);
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
BOOL gcc_write_server_data_blocks(wStream* s, rdpMcs* mcs)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2015-04-01 17:58:25 +03:00
|
|
|
return gcc_write_server_core_data(s, mcs) && /* serverCoreData */
|
2015-04-01 16:11:57 +03:00
|
|
|
gcc_write_server_network_data(s, mcs) && /* serverNetworkData */
|
|
|
|
gcc_write_server_security_data(s, mcs) && /* serverSecurityData */
|
|
|
|
gcc_write_server_message_channel_data(s, mcs); /* serverMessageChannelData */
|
2014-01-24 02:41:05 +04:00
|
|
|
|
|
|
|
/* TODO: Send these GCC data blocks only when the client sent them */
|
|
|
|
//gcc_write_server_multitransport_channel_data(s, settings); /* serverMultitransportChannelData */
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL gcc_read_user_data_header(wStream* s, UINT16* type, UINT16* length)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, *type); /* type */
|
|
|
|
Stream_Read_UINT16(s, *length); /* length */
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (*length - 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 01:28:30 +04:00
|
|
|
}
|
|
|
|
|
2011-07-06 02:26:12 +04:00
|
|
|
/**
|
|
|
|
* Write a user data header (TS_UD_HEADER).\n
|
|
|
|
* @msdn{cc240509}
|
|
|
|
* @param s stream
|
|
|
|
* @param type data block type
|
|
|
|
* @param length data block length
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
void gcc_write_user_data_header(wStream* s, UINT16 type, UINT16 length)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, type); /* type */
|
|
|
|
Stream_Write_UINT16(s, length); /* length */
|
2011-07-06 02:26:12 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a client core data block (TS_UD_CS_CORE).\n
|
|
|
|
* @msdn{cc240510}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2013-01-16 04:14:03 +04:00
|
|
|
char* str = NULL;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 version;
|
2014-09-24 02:19:05 +04:00
|
|
|
BYTE connectionType = 0;
|
2014-09-22 19:38:33 +04:00
|
|
|
UINT32 clientColorDepth;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 colorDepth = 0;
|
|
|
|
UINT16 postBeta2ColorDepth = 0;
|
|
|
|
UINT16 highColorDepth = 0;
|
|
|
|
UINT16 supportedColorDepths = 0;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 serverSelectedProtocol = 0;
|
2014-09-22 19:38:33 +04:00
|
|
|
UINT16 earlyCapabilityFlags = 0;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* Length of all required fields, until imeFileName */
|
|
|
|
if (blockLength < 128)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT32(s, version); /* version (4 bytes) */
|
2012-11-07 19:33:06 +04:00
|
|
|
settings->RdpVersion = (version == RDP_VERSION_4 ? 4 : 7);
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT16(s, settings->DesktopWidth); /* DesktopWidth (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, settings->DesktopHeight); /* DesktopHeight (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, colorDepth); /* ColorDepth (2 bytes) */
|
|
|
|
Stream_Seek_UINT16(s); /* SASSequence (Secure Access Sequence) (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, settings->ClientBuild); /* ClientBuild (4 bytes) */
|
2012-02-11 17:22:13 +04:00
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
|
2013-04-30 06:35:15 +04:00
|
|
|
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 32 / 2, &str, 0, NULL, NULL);
|
|
|
|
Stream_Seek(s, 32);
|
2016-01-21 16:47:10 +03:00
|
|
|
free(settings->ClientHostname);
|
|
|
|
settings->ClientHostname = str;
|
2013-01-16 04:14:03 +04:00
|
|
|
str = NULL;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT32(s, settings->KeyboardType); /* KeyboardType (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey (4 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek(s, 64); /* imeFileName (64 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
blockLength -= 128;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The following fields are all optional. If one field is present, all of the preceding
|
|
|
|
* fields MUST also be present. If one field is not present, all of the subsequent fields
|
|
|
|
* MUST NOT be present.
|
|
|
|
* We must check the bytes left before reading each field.
|
|
|
|
*/
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT16(s, postBeta2ColorDepth); /* postBeta2ColorDepth (2 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek_UINT16(s); /* clientProductID (2 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek_UINT32(s); /* serialNumber (4 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 4;
|
|
|
|
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT16(s, highColorDepth); /* highColorDepth (2 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT16(s, supportedColorDepths); /* supportedColorDepths (2 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2014-09-22 19:38:33 +04:00
|
|
|
Stream_Read_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags (2 bytes) */
|
|
|
|
settings->EarlyCapabilityFlags = (UINT32) earlyCapabilityFlags;
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 64)
|
|
|
|
break;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL);
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek(s, 64); /* clientDigProductId (64 bytes) */
|
2016-01-21 16:47:10 +03:00
|
|
|
free(settings->ClientProductId);
|
|
|
|
settings->ClientProductId = str;
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 64;
|
|
|
|
|
|
|
|
if (blockLength < 1)
|
|
|
|
break;
|
2014-09-24 02:19:05 +04:00
|
|
|
Stream_Read_UINT8(s, connectionType); /* connectionType (1 byte) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 1;
|
|
|
|
|
|
|
|
if (blockLength < 1)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Seek_UINT8(s); /* pad1octet (1 byte) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 1;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT32(s, serverSelectedProtocol); /* serverSelectedProtocol (4 bytes) */
|
|
|
|
blockLength -= 4;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2015-08-27 11:18:22 +03:00
|
|
|
Stream_Read_UINT32(s, settings->DesktopPhysicalWidth); /* desktopPhysicalWidth (4 bytes) */
|
2014-01-24 01:00:02 +04:00
|
|
|
blockLength -= 4;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2015-08-27 11:18:22 +03:00
|
|
|
Stream_Read_UINT32(s, settings->DesktopPhysicalHeight); /* desktopPhysicalHeight (4 bytes) */
|
2014-01-24 01:00:02 +04:00
|
|
|
blockLength -= 4;
|
|
|
|
|
|
|
|
if (blockLength < 2)
|
|
|
|
break;
|
2015-08-27 11:18:22 +03:00
|
|
|
Stream_Read_UINT16(s, settings->DesktopOrientation); /* desktopOrientation (2 bytes) */
|
2014-01-24 01:00:02 +04:00
|
|
|
blockLength -= 2;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2015-08-27 11:18:22 +03:00
|
|
|
Stream_Read_UINT32(s, settings->DesktopScaleFactor); /* desktopScaleFactor (4 bytes) */
|
2014-01-24 01:00:02 +04:00
|
|
|
blockLength -= 4;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
break;
|
2015-08-27 11:18:22 +03:00
|
|
|
Stream_Read_UINT32(s, settings->DeviceScaleFactor); /* deviceScaleFactor (4 bytes) */
|
2011-08-19 13:39:37 +04:00
|
|
|
blockLength -= 4;
|
|
|
|
|
2012-11-07 20:02:46 +04:00
|
|
|
if (settings->SelectedProtocol != serverSelectedProtocol)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
} while (0);
|
|
|
|
|
2011-08-19 14:11:33 +04:00
|
|
|
if (highColorDepth > 0)
|
2012-11-07 19:33:06 +04:00
|
|
|
{
|
2014-09-22 19:38:33 +04:00
|
|
|
if (earlyCapabilityFlags & RNS_UD_CS_WANT_32BPP_SESSION)
|
|
|
|
clientColorDepth = 32;
|
2013-01-28 02:17:04 +04:00
|
|
|
else
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = highColorDepth;
|
2012-11-07 19:33:06 +04:00
|
|
|
}
|
2011-08-19 14:11:33 +04:00
|
|
|
else if (postBeta2ColorDepth > 0)
|
|
|
|
{
|
|
|
|
switch (postBeta2ColorDepth)
|
|
|
|
{
|
|
|
|
case RNS_UD_COLOR_4BPP:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 4;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
case RNS_UD_COLOR_8BPP:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 8;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
case RNS_UD_COLOR_16BPP_555:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 15;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
case RNS_UD_COLOR_16BPP_565:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 16;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
case RNS_UD_COLOR_24BPP:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 24;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
default:
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (colorDepth)
|
|
|
|
{
|
|
|
|
case RNS_UD_COLOR_4BPP:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 4;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
case RNS_UD_COLOR_8BPP:
|
2014-09-22 19:38:33 +04:00
|
|
|
clientColorDepth = 8;
|
2011-08-19 14:11:33 +04:00
|
|
|
break;
|
|
|
|
default:
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-11 17:22:13 +04:00
|
|
|
/*
|
2012-09-24 03:49:13 +04:00
|
|
|
* If we are in server mode, accept client's color depth only if
|
2012-02-11 17:22:13 +04:00
|
|
|
* it is smaller than ours. This is what Windows server does.
|
|
|
|
*/
|
2014-09-22 19:38:33 +04:00
|
|
|
if ((clientColorDepth < settings->ColorDepth) || !settings->ServerMode)
|
|
|
|
settings->ColorDepth = clientColorDepth;
|
|
|
|
|
|
|
|
if (settings->NetworkAutoDetect)
|
|
|
|
settings->NetworkAutoDetect = (earlyCapabilityFlags & RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (settings->SupportHeartbeatPdu)
|
|
|
|
settings->SupportHeartbeatPdu = (earlyCapabilityFlags & RNS_UD_CS_SUPPORT_HEARTBEAT_PDU) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (settings->SupportGraphicsPipeline)
|
|
|
|
settings->SupportGraphicsPipeline = (earlyCapabilityFlags & RNS_UD_CS_SUPPORT_DYNVC_GFX_PROTOCOL) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (settings->SupportDynamicTimeZone)
|
|
|
|
settings->SupportDynamicTimeZone = (earlyCapabilityFlags & RNS_UD_CS_SUPPORT_DYNAMIC_TIME_ZONE) ? TRUE : FALSE;
|
2012-02-11 17:22:13 +04:00
|
|
|
|
2016-01-20 18:54:15 +03:00
|
|
|
if (settings->SupportMonitorLayoutPdu)
|
|
|
|
settings->SupportMonitorLayoutPdu = (earlyCapabilityFlags & RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU) ? TRUE : FALSE;
|
|
|
|
|
2014-09-24 02:19:05 +04:00
|
|
|
if (!(earlyCapabilityFlags & RNS_UD_CS_VALID_CONNECTION_TYPE))
|
|
|
|
connectionType = 0;
|
|
|
|
|
2015-01-13 19:09:36 +03:00
|
|
|
settings->SupportErrorInfoPdu = earlyCapabilityFlags & RNS_UD_CS_SUPPORT_ERRINFO_PDU;
|
|
|
|
|
2014-09-24 02:19:05 +04:00
|
|
|
settings->ConnectionType = connectionType;
|
2012-02-11 17:22:13 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 06:02:00 +04:00
|
|
|
/**
|
|
|
|
* Write a client core data block (TS_UD_CS_CORE).\n
|
|
|
|
* @msdn{cc240510}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_core_data(wStream* s, rdpMcs* mcs)
|
2011-07-05 06:02:00 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 version;
|
2013-01-11 00:30:32 +04:00
|
|
|
WCHAR* clientName = NULL;
|
2012-09-24 03:49:13 +04:00
|
|
|
int clientNameLength;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE connectionType;
|
|
|
|
UINT16 highColorDepth;
|
|
|
|
UINT16 supportedColorDepths;
|
|
|
|
UINT16 earlyCapabilityFlags;
|
2013-01-11 00:30:32 +04:00
|
|
|
WCHAR* clientDigProductId = NULL;
|
2012-09-24 03:49:13 +04:00
|
|
|
int clientDigProductIdLength;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2015-08-27 11:18:22 +03:00
|
|
|
gcc_write_user_data_header(s, CS_CORE, 234);
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
version = settings->RdpVersion >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
|
2012-09-24 03:49:13 +04:00
|
|
|
|
2012-12-17 19:20:25 +04:00
|
|
|
clientNameLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientHostname, -1, &clientName, 0);
|
|
|
|
clientDigProductIdLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientProductId, -1, &clientDigProductId, 0);
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, version); /* Version */
|
|
|
|
Stream_Write_UINT16(s, settings->DesktopWidth); /* DesktopWidth */
|
|
|
|
Stream_Write_UINT16(s, settings->DesktopHeight); /* DesktopHeight */
|
|
|
|
Stream_Write_UINT16(s, RNS_UD_COLOR_8BPP); /* ColorDepth, ignored because of postBeta2ColorDepth */
|
|
|
|
Stream_Write_UINT16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */
|
|
|
|
Stream_Write_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */
|
|
|
|
Stream_Write_UINT32(s, settings->ClientBuild); /* ClientBuild */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2011-07-08 08:37:25 +04:00
|
|
|
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
|
2012-09-24 03:49:13 +04:00
|
|
|
|
2012-12-18 17:55:43 +04:00
|
|
|
if (clientNameLength >= 16)
|
2011-07-08 08:37:25 +04:00
|
|
|
{
|
2012-12-18 17:55:43 +04:00
|
|
|
clientNameLength = 16;
|
2014-09-22 19:38:33 +04:00
|
|
|
clientName[clientNameLength - 1] = 0;
|
2011-07-08 08:37:25 +04:00
|
|
|
}
|
2012-09-24 03:49:13 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, clientName, (clientNameLength * 2));
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 32 - (clientNameLength * 2));
|
2012-10-09 07:21:26 +04:00
|
|
|
free(clientName);
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, settings->KeyboardType); /* KeyboardType */
|
|
|
|
Stream_Write_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */
|
|
|
|
Stream_Write_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 64); /* imeFileName */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */
|
|
|
|
Stream_Write_UINT16(s, 1); /* clientProductID */
|
|
|
|
Stream_Write_UINT32(s, 0); /* serialNumber (should be initialized to 0) */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
highColorDepth = MIN(settings->ColorDepth, 24);
|
2011-07-08 23:32:06 +04:00
|
|
|
|
|
|
|
supportedColorDepths =
|
|
|
|
RNS_UD_24BPP_SUPPORT |
|
|
|
|
RNS_UD_16BPP_SUPPORT |
|
|
|
|
RNS_UD_15BPP_SUPPORT;
|
2011-07-06 02:26:12 +04:00
|
|
|
|
|
|
|
earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;
|
|
|
|
|
2014-09-25 01:23:12 +04:00
|
|
|
if (settings->NetworkAutoDetect)
|
|
|
|
settings->ConnectionType = CONNECTION_TYPE_AUTODETECT;
|
|
|
|
|
|
|
|
if (settings->RemoteFxCodec && !settings->NetworkAutoDetect)
|
|
|
|
settings->ConnectionType = CONNECTION_TYPE_LAN;
|
|
|
|
|
|
|
|
connectionType = settings->ConnectionType;
|
2011-12-16 21:14:16 +04:00
|
|
|
|
2014-09-22 19:38:33 +04:00
|
|
|
if (connectionType)
|
2011-12-16 21:14:16 +04:00
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
if (settings->ColorDepth == 32)
|
2011-07-08 08:37:25 +04:00
|
|
|
{
|
|
|
|
supportedColorDepths |= RNS_UD_32BPP_SUPPORT;
|
2011-07-06 02:26:12 +04:00
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION;
|
2011-07-08 08:37:25 +04:00
|
|
|
}
|
|
|
|
|
2013-10-22 07:33:25 +04:00
|
|
|
if (settings->NetworkAutoDetect)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT;
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
if (settings->SupportHeartbeatPdu)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_SUPPORT_HEARTBEAT_PDU;
|
|
|
|
|
2013-10-22 07:33:25 +04:00
|
|
|
if (settings->SupportGraphicsPipeline)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_SUPPORT_DYNVC_GFX_PROTOCOL;
|
|
|
|
|
|
|
|
if (settings->SupportDynamicTimeZone)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_SUPPORT_DYNAMIC_TIME_ZONE;
|
|
|
|
|
2016-01-20 18:54:15 +03:00
|
|
|
if (settings->SupportMonitorLayoutPdu)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, highColorDepth); /* highColorDepth */
|
|
|
|
Stream_Write_UINT16(s, supportedColorDepths); /* supportedColorDepths */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
|
2011-07-08 08:37:25 +04:00
|
|
|
|
2012-12-18 17:55:43 +04:00
|
|
|
/* clientDigProductId (64 bytes, null-terminated unicode, truncated to 31 characters) */
|
|
|
|
if (clientDigProductIdLength >= 32)
|
2011-07-08 08:37:25 +04:00
|
|
|
{
|
2012-12-18 17:55:43 +04:00
|
|
|
clientDigProductIdLength = 32;
|
2014-09-22 19:38:33 +04:00
|
|
|
clientDigProductId[clientDigProductIdLength - 1] = 0;
|
2011-07-08 08:37:25 +04:00
|
|
|
}
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, clientDigProductId, (clientDigProductIdLength * 2) );
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 64 - (clientDigProductIdLength * 2) );
|
2012-10-09 07:21:26 +04:00
|
|
|
free(clientDigProductId);
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, connectionType); /* connectionType */
|
|
|
|
Stream_Write_UINT8(s, 0); /* pad1octet */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, settings->SelectedProtocol); /* serverSelectedProtocol */
|
2015-08-27 11:18:22 +03:00
|
|
|
|
|
|
|
Stream_Write_UINT32(s, settings->DesktopPhysicalWidth); /* desktopPhysicalWidth */
|
|
|
|
Stream_Write_UINT32(s, settings->DesktopPhysicalHeight); /* desktopPhysicalHeight */
|
|
|
|
Stream_Write_UINT16(s, settings->DesktopOrientation); /* desktopOrientation */
|
|
|
|
Stream_Write_UINT32(s, settings->DesktopScaleFactor); /* desktopScaleFactor */
|
|
|
|
Stream_Write_UINT32(s, settings->DeviceScaleFactor); /* deviceScaleFactor */
|
2011-07-05 06:02:00 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_core_data(wStream* s, rdpMcs* mcs)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 version;
|
|
|
|
UINT32 clientRequestedProtocols;
|
2014-01-24 22:03:37 +04:00
|
|
|
UINT32 earlyCapabilityFlags;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2014-01-24 22:03:37 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
2014-01-24 22:03:37 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, version); /* version */
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
if (version == RDP_VERSION_4 && settings->RdpVersion > 4)
|
|
|
|
settings->RdpVersion = 4;
|
|
|
|
else if (version == RDP_VERSION_5_PLUS && settings->RdpVersion < 5)
|
|
|
|
settings->RdpVersion = 7;
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2014-01-24 22:03:37 +04:00
|
|
|
if (Stream_GetRemainingLength(s) >= 4)
|
|
|
|
{
|
|
|
|
Stream_Read_UINT32(s, clientRequestedProtocols); /* clientRequestedProtocols */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) >= 4)
|
|
|
|
{
|
|
|
|
Stream_Read_UINT32(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
|
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
BOOL gcc_write_server_core_data(wStream* s, rdpMcs* mcs)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2014-09-22 19:38:33 +04:00
|
|
|
UINT32 version;
|
|
|
|
UINT32 earlyCapabilityFlags = 0;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 20))
|
|
|
|
return FALSE;
|
|
|
|
|
2014-01-24 22:03:37 +04:00
|
|
|
gcc_write_user_data_header(s, SC_CORE, 16);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2014-09-22 19:38:33 +04:00
|
|
|
version = settings->RdpVersion == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS;
|
|
|
|
|
|
|
|
if (settings->SupportDynamicTimeZone)
|
|
|
|
earlyCapabilityFlags |= RNS_UD_SC_DYNAMIC_DST_SUPPORTED;
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, version); /* version (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, settings->RequestedProtocols); /* clientRequestedProtocols (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, earlyCapabilityFlags); /* earlyCapabilityFlags (4 bytes) */
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a client security data block (TS_UD_CS_SEC).\n
|
|
|
|
* @msdn{cc240511}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_security_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
2011-08-19 14:11:33 +04:00
|
|
|
if (blockLength < 8)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
if (settings->UseRdpSecurityLayer)
|
2012-01-25 20:04:19 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */
|
2012-11-08 08:29:24 +04:00
|
|
|
if (settings->EncryptionMethods == 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */
|
2014-04-02 16:17:39 +04:00
|
|
|
else
|
|
|
|
Stream_Seek(s, 4);
|
2012-01-25 20:04:19 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 8);
|
2012-01-25 20:04:19 +04:00
|
|
|
}
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 06:02:00 +04:00
|
|
|
/**
|
|
|
|
* Write a client security data block (TS_UD_CS_SEC).\n
|
|
|
|
* @msdn{cc240511}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_security_data(wStream* s, rdpMcs* mcs)
|
2011-07-05 06:02:00 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
2011-07-06 02:26:12 +04:00
|
|
|
gcc_write_user_data_header(s, CS_SECURITY, 12);
|
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
if (settings->UseRdpSecurityLayer)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */
|
|
|
|
Stream_Write_UINT32(s, 0); /* extEncryptionMethods */
|
2011-07-06 02:26:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* French locale, disable encryption */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, 0); /* encryptionMethods */
|
|
|
|
Stream_Write_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */
|
2011-07-06 02:26:12 +04:00
|
|
|
}
|
2011-07-05 06:02:00 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_security_data(wStream* s, rdpMcs* mcs)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* data;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 length;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
BOOL validCryptoConfig = FALSE;
|
|
|
|
UINT32 serverEncryptionMethod;
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 8)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
2014-02-14 02:50:38 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
Stream_Read_UINT32(s, serverEncryptionMethod); /* encryptionMethod */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */
|
2011-07-10 05:04:57 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
/* Only accept valid/known encryption methods */
|
|
|
|
switch (serverEncryptionMethod)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
case ENCRYPTION_METHOD_NONE:
|
|
|
|
WLog_DBG(TAG, "Server rdp encryption method: NONE");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_40BIT:
|
|
|
|
WLog_DBG(TAG, "Server rdp encryption method: 40BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_56BIT:
|
|
|
|
WLog_DBG(TAG, "Server rdp encryption method: 56BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_128BIT:
|
|
|
|
WLog_DBG(TAG, "Server rdp encryption method: 128BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_FIPS:
|
|
|
|
WLog_DBG(TAG, "Server rdp encryption method: FIPS");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "Received unknown encryption method %08X", serverEncryptionMethod);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->UseRdpSecurityLayer && !(settings->EncryptionMethods & serverEncryptionMethod))
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Server uses non-advertised encryption method 0x%08X", serverEncryptionMethod);
|
|
|
|
/* FIXME: Should we return FALSE; in this case ?? */
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->EncryptionMethods = serverEncryptionMethod;
|
|
|
|
|
|
|
|
/* Verify encryption level/method combinations according to MS-RDPBCGR Section 5.3.2 */
|
|
|
|
switch (settings->EncryptionLevel)
|
|
|
|
{
|
|
|
|
case ENCRYPTION_LEVEL_NONE:
|
|
|
|
if (settings->EncryptionMethods == ENCRYPTION_METHOD_NONE)
|
|
|
|
{
|
|
|
|
validCryptoConfig = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_FIPS:
|
|
|
|
if (settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
|
|
|
|
{
|
|
|
|
validCryptoConfig = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_LOW:
|
|
|
|
case ENCRYPTION_LEVEL_HIGH:
|
|
|
|
case ENCRYPTION_LEVEL_CLIENT_COMPATIBLE:
|
|
|
|
if (settings->EncryptionMethods == ENCRYPTION_METHOD_40BIT ||
|
|
|
|
settings->EncryptionMethods == ENCRYPTION_METHOD_56BIT ||
|
|
|
|
settings->EncryptionMethods == ENCRYPTION_METHOD_128BIT ||
|
|
|
|
settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
|
|
|
|
{
|
|
|
|
validCryptoConfig = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "Received unknown encryption level %08X", settings->EncryptionLevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validCryptoConfig)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Received invalid cryptographic configuration (level=0x%08X method=0x%08X)",
|
|
|
|
settings->EncryptionLevel, settings->EncryptionMethods);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->EncryptionLevel == ENCRYPTION_LEVEL_NONE)
|
|
|
|
{
|
|
|
|
/* serverRandomLen and serverCertLen must not be present */
|
|
|
|
settings->UseRdpSecurityLayer = FALSE;
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 8)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
2014-02-14 02:50:38 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, settings->ServerRandomLength); /* serverRandomLen */
|
|
|
|
Stream_Read_UINT32(s, settings->ServerCertificateLength); /* serverCertLen */
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < settings->ServerRandomLength + settings->ServerCertificateLength)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2014-05-10 00:37:47 +04:00
|
|
|
if ((settings->ServerRandomLength <= 0) || (settings->ServerCertificateLength <= 0))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2014-05-10 00:37:47 +04:00
|
|
|
/* serverRandom */
|
|
|
|
settings->ServerRandom = (BYTE*) malloc(settings->ServerRandomLength);
|
|
|
|
if (!settings->ServerRandom)
|
|
|
|
return FALSE;
|
|
|
|
Stream_Read(s, settings->ServerRandom, settings->ServerRandomLength);
|
2012-09-24 12:40:32 +04:00
|
|
|
|
2012-01-14 23:42:36 +04:00
|
|
|
|
2014-05-10 00:37:47 +04:00
|
|
|
/* serverCertificate */
|
|
|
|
settings->ServerCertificate = (BYTE*) malloc(settings->ServerCertificateLength);
|
|
|
|
if (!settings->ServerCertificate)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2014-05-10 00:37:47 +04:00
|
|
|
Stream_Read(s, settings->ServerCertificate, settings->ServerCertificateLength);
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2014-05-10 00:37:47 +04:00
|
|
|
certificate_free(settings->RdpServerCertificate);
|
|
|
|
settings->RdpServerCertificate = certificate_new();
|
|
|
|
if (!settings->RdpServerCertificate)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
data = settings->ServerCertificate;
|
|
|
|
length = settings->ServerCertificateLength;
|
|
|
|
|
|
|
|
return certificate_read_server_certificate(settings->RdpServerCertificate, data, length);
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
static const BYTE initial_signature[] =
|
2012-01-30 00:05:34 +04:00
|
|
|
{
|
2012-01-25 20:00:40 +04:00
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01
|
2012-02-21 09:56:55 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Terminal Services Signing Keys.
|
|
|
|
* Yes, Terminal Services Private Key is publicly available.
|
|
|
|
*/
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
const BYTE tssk_modulus[] =
|
2012-02-21 09:56:55 +04:00
|
|
|
{
|
|
|
|
0x3d, 0x3a, 0x5e, 0xbd, 0x72, 0x43, 0x3e, 0xc9,
|
|
|
|
0x4d, 0xbb, 0xc1, 0x1e, 0x4a, 0xba, 0x5f, 0xcb,
|
|
|
|
0x3e, 0x88, 0x20, 0x87, 0xef, 0xf5, 0xc1, 0xe2,
|
|
|
|
0xd7, 0xb7, 0x6b, 0x9a, 0xf2, 0x52, 0x45, 0x95,
|
|
|
|
0xce, 0x63, 0x65, 0x6b, 0x58, 0x3a, 0xfe, 0xef,
|
|
|
|
0x7c, 0xe7, 0xbf, 0xfe, 0x3d, 0xf6, 0x5c, 0x7d,
|
|
|
|
0x6c, 0x5e, 0x06, 0x09, 0x1a, 0xf5, 0x61, 0xbb,
|
|
|
|
0x20, 0x93, 0x09, 0x5f, 0x05, 0x6d, 0xea, 0x87
|
|
|
|
};
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
const BYTE tssk_privateExponent[] =
|
2012-02-21 09:56:55 +04:00
|
|
|
{
|
|
|
|
0x87, 0xa7, 0x19, 0x32, 0xda, 0x11, 0x87, 0x55,
|
|
|
|
0x58, 0x00, 0x16, 0x16, 0x25, 0x65, 0x68, 0xf8,
|
|
|
|
0x24, 0x3e, 0xe6, 0xfa, 0xe9, 0x67, 0x49, 0x94,
|
|
|
|
0xcf, 0x92, 0xcc, 0x33, 0x99, 0xe8, 0x08, 0x60,
|
|
|
|
0x17, 0x9a, 0x12, 0x9f, 0x24, 0xdd, 0xb1, 0x24,
|
|
|
|
0x99, 0xc7, 0x3a, 0xb8, 0x0a, 0x7b, 0x0d, 0xdd,
|
|
|
|
0x35, 0x07, 0x79, 0x17, 0x0b, 0x51, 0x9b, 0xb3,
|
|
|
|
0xc7, 0x10, 0x01, 0x13, 0xe7, 0x3f, 0xf3, 0x5f
|
|
|
|
};
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
const BYTE tssk_exponent[] =
|
2012-02-21 09:56:55 +04:00
|
|
|
{
|
|
|
|
0x5b, 0x7b, 0x88, 0xc0
|
2012-01-25 20:00:40 +04:00
|
|
|
};
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
BOOL gcc_write_server_security_data(wStream* s, rdpMcs* mcs)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2012-01-30 00:05:34 +04:00
|
|
|
CryptoMd5 md5;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* sigData;
|
2012-01-25 20:00:40 +04:00
|
|
|
int expLen, keyLen, sigDataLen;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE encryptedSignature[TSSK_KEY_LENGTH];
|
|
|
|
BYTE signature[sizeof(initial_signature)];
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 headerLen, serverRandomLen, serverCertLen, wPublicKeyBlobLen;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2012-01-25 20:00:40 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
/**
|
|
|
|
* Re: settings->EncryptionLevel:
|
|
|
|
* This is configured/set by the server implementation and serves the same
|
|
|
|
* purpose as the "Encryption Level" setting in the RDP-Tcp configuration
|
|
|
|
* dialog of Microsoft's Remote Desktop Session Host Configuration.
|
|
|
|
* Re: settings->EncryptionMethods:
|
|
|
|
* at this point this setting contains the client's supported encryption
|
|
|
|
* methods we've received in gcc_read_client_security_data()
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!settings->UseRdpSecurityLayer)
|
2012-01-30 00:05:34 +04:00
|
|
|
{
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
/* TLS/NLA is used: disable rdp style encryption */
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->EncryptionLevel = ENCRYPTION_LEVEL_NONE;
|
2012-01-25 20:00:40 +04:00
|
|
|
}
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
|
|
|
|
/* verify server encryption level value */
|
|
|
|
switch (settings->EncryptionLevel)
|
2012-01-25 20:00:40 +04:00
|
|
|
{
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
case ENCRYPTION_LEVEL_NONE:
|
|
|
|
WLog_INFO(TAG, "Active rdp encryption level: NONE");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_FIPS:
|
|
|
|
WLog_INFO(TAG, "Active rdp encryption level: FIPS Compliant");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_HIGH:
|
|
|
|
WLog_INFO(TAG, "Active rdp encryption level: HIGH");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_LOW:
|
|
|
|
WLog_INFO(TAG, "Active rdp encryption level: LOW");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_CLIENT_COMPATIBLE:
|
|
|
|
WLog_INFO(TAG, "Active rdp encryption level: CLIENT-COMPATIBLE");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "Invalid server encryption level 0x%08X", settings->EncryptionLevel);
|
|
|
|
WLog_ERR(TAG, "Switching to encryption level CLIENT-COMPATIBLE");
|
|
|
|
settings->EncryptionLevel = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
|
2012-01-25 20:00:40 +04:00
|
|
|
}
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
|
|
|
|
/* choose rdp encryption method based on server level and client methods */
|
|
|
|
switch (settings->EncryptionLevel)
|
2014-04-02 16:17:39 +04:00
|
|
|
{
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
case ENCRYPTION_LEVEL_NONE:
|
|
|
|
/* The only valid method is NONE in this case */
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_NONE;
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_FIPS:
|
|
|
|
/* The only valid method is FIPS in this case */
|
|
|
|
if (!(settings->EncryptionMethods & ENCRYPTION_METHOD_FIPS))
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "client does not support FIPS as required by server configuration");
|
|
|
|
}
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_FIPS;
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_HIGH:
|
|
|
|
/* Maximum key strength supported by the server must be used (128 bit)*/
|
|
|
|
if (!(settings->EncryptionMethods & ENCRYPTION_METHOD_128BIT))
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "client does not support 128 bit encryption method as required by server configuration");
|
|
|
|
}
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_128BIT;
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_LEVEL_LOW:
|
|
|
|
case ENCRYPTION_LEVEL_CLIENT_COMPATIBLE:
|
|
|
|
/* Maximum key strength supported by the client must be used */
|
|
|
|
if (settings->EncryptionMethods & ENCRYPTION_METHOD_128BIT)
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_128BIT;
|
|
|
|
else if (settings->EncryptionMethods & ENCRYPTION_METHOD_56BIT)
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_56BIT;
|
|
|
|
else if (settings->EncryptionMethods & ENCRYPTION_METHOD_40BIT)
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_40BIT;
|
|
|
|
else if (settings->EncryptionMethods & ENCRYPTION_METHOD_FIPS)
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_FIPS;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "client has not announced any supported encryption methods");
|
|
|
|
settings->EncryptionMethods = ENCRYPTION_METHOD_128BIT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "internal error: unknown encryption level");
|
2015-04-01 16:11:57 +03:00
|
|
|
return FALSE;
|
2014-04-02 16:17:39 +04:00
|
|
|
}
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
|
|
|
|
/* log selected encryption method */
|
|
|
|
switch (settings->EncryptionMethods)
|
2012-01-25 20:00:40 +04:00
|
|
|
{
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
case ENCRYPTION_METHOD_NONE:
|
|
|
|
WLog_INFO(TAG, "Selected rdp encryption method: NONE");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_40BIT:
|
|
|
|
WLog_INFO(TAG, "Selected rdp encryption method: 40BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_56BIT:
|
|
|
|
WLog_INFO(TAG, "Selected rdp encryption method: 56BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_128BIT:
|
|
|
|
WLog_INFO(TAG, "Selected rdp encryption method: 128BIT");
|
|
|
|
break;
|
|
|
|
case ENCRYPTION_METHOD_FIPS:
|
|
|
|
WLog_INFO(TAG, "Selected rdp encryption method: FIPS");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "internal error: unknown encryption method");
|
2015-04-01 16:11:57 +03:00
|
|
|
return FALSE;
|
2012-01-25 20:00:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
headerLen = 12;
|
|
|
|
keyLen = 0;
|
|
|
|
wPublicKeyBlobLen = 0;
|
|
|
|
serverRandomLen = 0;
|
|
|
|
serverCertLen = 0;
|
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
if (settings->EncryptionMethods != ENCRYPTION_METHOD_NONE)
|
2012-01-30 00:05:34 +04:00
|
|
|
{
|
2012-01-25 20:00:40 +04:00
|
|
|
serverRandomLen = 32;
|
|
|
|
|
2012-11-08 08:29:24 +04:00
|
|
|
keyLen = settings->RdpServerRsaKey->ModulusLength;
|
|
|
|
expLen = sizeof(settings->RdpServerRsaKey->exponent);
|
2012-01-25 20:00:40 +04:00
|
|
|
wPublicKeyBlobLen = 4; /* magic (RSA1) */
|
|
|
|
wPublicKeyBlobLen += 4; /* keylen */
|
|
|
|
wPublicKeyBlobLen += 4; /* bitlen */
|
|
|
|
wPublicKeyBlobLen += 4; /* datalen */
|
|
|
|
wPublicKeyBlobLen += expLen;
|
|
|
|
wPublicKeyBlobLen += keyLen;
|
|
|
|
wPublicKeyBlobLen += 8; /* 8 bytes of zero padding */
|
|
|
|
|
|
|
|
serverCertLen = 4; /* dwVersion */
|
|
|
|
serverCertLen += 4; /* dwSigAlgId */
|
|
|
|
serverCertLen += 4; /* dwKeyAlgId */
|
|
|
|
serverCertLen += 2; /* wPublicKeyBlobType */
|
|
|
|
serverCertLen += 2; /* wPublicKeyBlobLen */
|
|
|
|
serverCertLen += wPublicKeyBlobLen;
|
|
|
|
serverCertLen += 2; /* wSignatureBlobType */
|
|
|
|
serverCertLen += 2; /* wSignatureBlobLen */
|
|
|
|
serverCertLen += sizeof(encryptedSignature); /* SignatureBlob */
|
|
|
|
serverCertLen += 8; /* 8 bytes of zero padding */
|
|
|
|
|
|
|
|
headerLen += sizeof(serverRandomLen);
|
|
|
|
headerLen += sizeof(serverCertLen);
|
|
|
|
headerLen += serverRandomLen;
|
|
|
|
headerLen += serverCertLen;
|
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLen + 4))
|
|
|
|
return FALSE;
|
2012-01-25 20:00:40 +04:00
|
|
|
gcc_write_user_data_header(s, SC_SECURITY, headerLen);
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */
|
|
|
|
Stream_Write_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */
|
2012-01-30 00:05:34 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
if (settings->EncryptionMethods == ENCRYPTION_METHOD_NONE)
|
2012-01-30 00:05:34 +04:00
|
|
|
{
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
2012-01-25 20:00:40 +04:00
|
|
|
}
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, serverRandomLen); /* serverRandomLen */
|
|
|
|
Stream_Write_UINT32(s, serverCertLen); /* serverCertLen */
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->ServerRandomLength = serverRandomLen;
|
|
|
|
settings->ServerRandom = (BYTE*) malloc(serverRandomLen);
|
|
|
|
crypto_nonce(settings->ServerRandom, serverRandomLen);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, settings->ServerRandom, serverRandomLen);
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
sigData = Stream_Pointer(s);
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */
|
|
|
|
Stream_Write_UINT32(s, KEY_EXCHANGE_ALG_RSA); /* dwKeyAlgId */
|
|
|
|
Stream_Write_UINT16(s, BB_RSA_KEY_BLOB); /* wPublicKeyBlobType */
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, wPublicKeyBlobLen); /* wPublicKeyBlobLen */
|
|
|
|
Stream_Write(s, "RSA1", 4); /* magic */
|
|
|
|
Stream_Write_UINT32(s, keyLen + 8); /* keylen */
|
|
|
|
Stream_Write_UINT32(s, keyLen * 8); /* bitlen */
|
|
|
|
Stream_Write_UINT32(s, keyLen - 1); /* datalen */
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, settings->RdpServerRsaKey->exponent, expLen);
|
|
|
|
Stream_Write(s, settings->RdpServerRsaKey->Modulus, keyLen);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 8);
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
sigDataLen = Stream_Pointer(s) - sigData;
|
2012-01-25 20:00:40 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */
|
2014-03-26 02:13:08 +04:00
|
|
|
Stream_Write_UINT16(s, sizeof(encryptedSignature) + 8); /* wSignatureBlobLen */
|
2012-01-25 20:00:40 +04:00
|
|
|
|
|
|
|
memcpy(signature, initial_signature, sizeof(initial_signature));
|
|
|
|
|
2012-01-30 00:05:34 +04:00
|
|
|
md5 = crypto_md5_init();
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!md5)
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "unable to allocate a md5");
|
2015-04-01 16:11:57 +03:00
|
|
|
return FALSE;
|
2014-03-26 02:13:08 +04:00
|
|
|
}
|
|
|
|
|
2012-01-30 00:05:34 +04:00
|
|
|
crypto_md5_update(md5, sigData, sigDataLen);
|
|
|
|
crypto_md5_final(md5, signature);
|
|
|
|
|
|
|
|
crypto_rsa_private_encrypt(signature, sizeof(signature), TSSK_KEY_LENGTH,
|
|
|
|
tssk_modulus, tssk_privateExponent, encryptedSignature);
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, encryptedSignature, sizeof(encryptedSignature));
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 8);
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a client network data block (TS_UD_CS_NET).\n
|
|
|
|
* @msdn{cc240512}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_network_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 i;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
|
|
|
if (blockLength < 4)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Read_UINT32(s, mcs->channelCount); /* channelCount */
|
2014-02-11 07:12:13 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
if (blockLength < 4 + mcs->channelCount * 12)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
if (mcs->channelCount > 16)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
|
|
|
/* channelDefArray */
|
2014-02-16 01:32:38 +04:00
|
|
|
for (i = 0; i < mcs->channelCount; i++)
|
2011-08-19 14:11:33 +04:00
|
|
|
{
|
|
|
|
/* CHANNEL_DEF */
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Read(s, mcs->channels[i].Name, 8); /* name (8 bytes) */
|
|
|
|
Stream_Read_UINT32(s, mcs->channels[i].options); /* options (4 bytes) */
|
2014-10-28 11:06:04 +03:00
|
|
|
mcs->channels[i].ChannelId = mcs->baseChannelId++;
|
2011-08-19 14:11:33 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 06:02:00 +04:00
|
|
|
/**
|
|
|
|
* Write a client network data block (TS_UD_CS_NET).\n
|
|
|
|
* @msdn{cc240512}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_network_data(wStream* s, rdpMcs* mcs)
|
2011-07-05 06:02:00 +04:00
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 i;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2011-07-05 06:02:00 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
if (mcs->channelCount > 0)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
2014-02-16 01:32:38 +04:00
|
|
|
length = mcs->channelCount * 12 + 8;
|
2011-07-06 02:26:12 +04:00
|
|
|
gcc_write_user_data_header(s, CS_NET, length);
|
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Write_UINT32(s, mcs->channelCount); /* channelCount */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
|
|
|
/* channelDefArray */
|
2014-02-16 01:32:38 +04:00
|
|
|
for (i = 0; i < mcs->channelCount; i++)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
|
|
|
/* CHANNEL_DEF */
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Write(s, mcs->channels[i].Name, 8); /* name (8 bytes) */
|
|
|
|
Stream_Write_UINT32(s, mcs->channels[i].options); /* options (4 bytes) */
|
2011-07-06 02:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-05 06:02:00 +04:00
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_network_data(wStream* s, rdpMcs* mcs)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 channelId;
|
2014-02-16 01:32:38 +04:00
|
|
|
UINT16 MCSChannelId;
|
|
|
|
UINT16 channelCount;
|
|
|
|
UINT16 parsedChannelCount;
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, MCSChannelId); /* MCSChannelId */
|
|
|
|
Stream_Read_UINT16(s, channelCount); /* channelCount */
|
2011-07-10 05:04:57 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
parsedChannelCount = channelCount;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
if (channelCount != mcs->channelCount)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "requested %d channels, got %d instead",
|
|
|
|
mcs->channelCount, channelCount);
|
2013-11-29 02:17:21 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
/* we ensure that the response is not bigger than the request */
|
2014-02-16 01:32:38 +04:00
|
|
|
|
|
|
|
if (channelCount > mcs->channelCount)
|
|
|
|
parsedChannelCount = mcs->channelCount;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) channelCount * 2)
|
2013-01-11 04:23:31 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
for (i = 0; i < parsedChannelCount; i++)
|
2011-07-10 05:04:57 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, channelId); /* channelId */
|
2014-02-16 01:32:38 +04:00
|
|
|
mcs->channels[i].ChannelId = channelId;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (channelCount % 2 == 1)
|
2013-05-09 01:48:30 +04:00
|
|
|
return Stream_SafeSeek(s, 2); /* padding */
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-10 05:04:57 +04:00
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
BOOL gcc_write_server_network_data(wStream* s, rdpMcs* mcs)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 i;
|
2015-04-01 16:11:57 +03:00
|
|
|
int payloadLen = 8 + mcs->channelCount * 2 + (mcs->channelCount % 2 == 1 ? 2 : 0);
|
|
|
|
|
2015-04-01 23:26:38 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, payloadLen + 4))
|
2015-04-01 16:11:57 +03:00
|
|
|
return FALSE;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
gcc_write_user_data_header(s, SC_NET, payloadLen);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Write_UINT16(s, mcs->channelCount); /* channelCount */
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
for (i = 0; i < mcs->channelCount; i++)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2014-02-16 01:32:38 +04:00
|
|
|
Stream_Write_UINT16(s, mcs->channels[i].ChannelId);
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2014-02-16 01:32:38 +04:00
|
|
|
if (mcs->channelCount % 2 == 1)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a client cluster data block (TS_UD_CS_CLUSTER).\n
|
|
|
|
* @msdn{cc240514}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_cluster_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 flags;
|
2014-01-24 01:00:02 +04:00
|
|
|
UINT32 redirectedSessionId;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
if (blockLength < 8)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, flags); /* flags */
|
2014-01-24 01:00:02 +04:00
|
|
|
Stream_Read_UINT32(s, redirectedSessionId); /* redirectedSessionId */
|
2011-08-19 14:11:33 +04:00
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
if (flags & REDIRECTED_SESSIONID_FIELD_VALID)
|
|
|
|
settings->RedirectedSessionId = redirectedSessionId;
|
2011-08-19 14:11:33 +04:00
|
|
|
|
2014-09-19 06:18:58 +04:00
|
|
|
if (blockLength != 8)
|
|
|
|
{
|
|
|
|
if (Stream_GetRemainingLength(s) >= (blockLength - 8))
|
|
|
|
{
|
|
|
|
/* The old Microsoft Mac RDP client can send a pad here */
|
|
|
|
Stream_Seek(s, (blockLength - 8));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 06:02:00 +04:00
|
|
|
/**
|
|
|
|
* Write a client cluster data block (TS_UD_CS_CLUSTER).\n
|
|
|
|
* @msdn{cc240514}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_cluster_data(wStream* s, rdpMcs* mcs)
|
2011-07-05 06:02:00 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 flags;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-07-06 02:26:12 +04:00
|
|
|
|
|
|
|
gcc_write_user_data_header(s, CS_CLUSTER, 12);
|
|
|
|
|
2011-07-08 08:37:25 +04:00
|
|
|
flags = REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2);
|
2011-07-05 06:02:00 +04:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
if (settings->ConsoleSession || settings->RedirectedSessionId)
|
2011-07-06 02:26:12 +04:00
|
|
|
flags |= REDIRECTED_SESSIONID_FIELD_VALID;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, flags); /* flags */
|
|
|
|
Stream_Write_UINT32(s, settings->RedirectedSessionId); /* redirectedSessionID */
|
2011-07-05 06:02:00 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read a client monitor data block (TS_UD_CS_MONITOR).\n
|
|
|
|
* @msdn{dd305336}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_monitor_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2014-01-24 01:00:02 +04:00
|
|
|
UINT32 index;
|
|
|
|
UINT32 flags;
|
|
|
|
UINT32 monitorCount;
|
2015-08-27 09:10:42 +03:00
|
|
|
UINT32 left, top, right, bottom;
|
|
|
|
rdpSettings* settings = mcs->settings;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
|
|
|
if (blockLength < 8)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT32(s, flags); /* flags */
|
|
|
|
Stream_Read_UINT32(s, monitorCount); /* monitorCount */
|
|
|
|
|
2016-01-14 23:00:41 +03:00
|
|
|
if (monitorCount > settings->MonitorDefArraySize)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "too many announced monitors(%d), clamping to %d", monitorCount, settings->MonitorDefArraySize);
|
|
|
|
monitorCount = settings->MonitorDefArraySize;
|
|
|
|
}
|
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (((blockLength - 8) / 20) < monitorCount)
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2015-08-27 09:10:42 +03:00
|
|
|
settings->MonitorCount = monitorCount;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
|
|
|
for (index = 0; index < monitorCount; index++)
|
|
|
|
{
|
2015-08-27 09:10:42 +03:00
|
|
|
Stream_Read_UINT32(s, left); /* left */
|
|
|
|
Stream_Read_UINT32(s, top); /* top */
|
|
|
|
Stream_Read_UINT32(s, right); /* right */
|
|
|
|
Stream_Read_UINT32(s, bottom); /* bottom */
|
|
|
|
Stream_Read_UINT32(s, flags); /* flags */
|
|
|
|
|
|
|
|
settings->MonitorDefArray[index].x = left;
|
|
|
|
settings->MonitorDefArray[index].y = top;
|
|
|
|
settings->MonitorDefArray[index].width = right - left + 1;
|
|
|
|
settings->MonitorDefArray[index].height = bottom - top + 1;
|
|
|
|
settings->MonitorDefArray[index].is_primary = (flags & MONITOR_PRIMARY);
|
2014-01-24 01:00:02 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-05 06:02:00 +04:00
|
|
|
/**
|
|
|
|
* Write a client monitor data block (TS_UD_CS_MONITOR).\n
|
|
|
|
* @msdn{dd305336}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_monitor_data(wStream* s, rdpMcs* mcs)
|
2011-07-05 06:02:00 +04:00
|
|
|
{
|
2011-07-06 02:26:12 +04:00
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 left, top, right, bottom, flags;
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2012-11-08 08:29:24 +04:00
|
|
|
if (settings->MonitorCount > 1)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
2012-11-08 08:29:24 +04:00
|
|
|
length = (20 * settings->MonitorCount) + 12;
|
2011-07-06 02:26:12 +04:00
|
|
|
gcc_write_user_data_header(s, CS_MONITOR, length);
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, 0); /* flags */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorCount); /* monitorCount */
|
2011-07-06 02:26:12 +04:00
|
|
|
|
2012-11-08 08:29:24 +04:00
|
|
|
for (i = 0; i < settings->MonitorCount; i++)
|
2011-07-06 02:26:12 +04:00
|
|
|
{
|
2012-11-08 08:29:24 +04:00
|
|
|
left = settings->MonitorDefArray[i].x;
|
|
|
|
top = settings->MonitorDefArray[i].y;
|
|
|
|
right = settings->MonitorDefArray[i].x + settings->MonitorDefArray[i].width - 1;
|
|
|
|
bottom = settings->MonitorDefArray[i].y + settings->MonitorDefArray[i].height - 1;
|
|
|
|
flags = settings->MonitorDefArray[i].is_primary ? MONITOR_PRIMARY : 0;
|
2011-07-05 06:02:00 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, left); /* left */
|
|
|
|
Stream_Write_UINT32(s, top); /* top */
|
|
|
|
Stream_Write_UINT32(s, right); /* right */
|
|
|
|
Stream_Write_UINT32(s, bottom); /* bottom */
|
|
|
|
Stream_Write_UINT32(s, flags); /* flags */
|
2011-07-06 02:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-05 06:02:00 +04:00
|
|
|
}
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_monitor_extended_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
|
|
|
UINT32 index;
|
|
|
|
UINT32 flags;
|
|
|
|
UINT32 monitorCount;
|
|
|
|
UINT32 monitorAttributeSize;
|
2015-08-27 09:10:42 +03:00
|
|
|
rdpSettings* settings = mcs->settings;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (blockLength < 12)
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT32(s, flags); /* flags */
|
|
|
|
Stream_Read_UINT32(s, monitorAttributeSize); /* monitorAttributeSize */
|
|
|
|
Stream_Read_UINT32(s, monitorCount); /* monitorCount */
|
|
|
|
|
|
|
|
if (monitorAttributeSize != 20)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if ((blockLength - 12) / monitorAttributeSize < monitorCount)
|
2014-01-24 01:00:02 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2015-08-27 09:10:42 +03:00
|
|
|
if (settings->MonitorCount != monitorCount)
|
2015-06-16 16:42:07 +03:00
|
|
|
return FALSE;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2015-08-27 09:10:42 +03:00
|
|
|
settings->HasMonitorAttributes = TRUE;
|
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
for (index = 0; index < monitorCount; index++)
|
|
|
|
{
|
2015-08-27 09:10:42 +03:00
|
|
|
Stream_Read_UINT32(s, settings->MonitorDefArray[index].attributes.physicalWidth); /* physicalWidth */
|
|
|
|
Stream_Read_UINT32(s, settings->MonitorDefArray[index].attributes.physicalHeight); /* physicalHeight */
|
|
|
|
Stream_Read_UINT32(s, settings->MonitorDefArray[index].attributes.orientation); /* orientation */
|
|
|
|
Stream_Read_UINT32(s, settings->MonitorDefArray[index].attributes.desktopScaleFactor); /* desktopScaleFactor */
|
|
|
|
Stream_Read_UINT32(s, settings->MonitorDefArray[index].attributes.deviceScaleFactor); /* deviceScaleFactor */
|
2014-01-24 01:00:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_monitor_extended_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
2015-08-27 09:10:42 +03:00
|
|
|
int i;
|
|
|
|
UINT16 length;
|
|
|
|
rdpSettings* settings = mcs->settings;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2015-08-27 09:10:42 +03:00
|
|
|
if (settings->HasMonitorAttributes)
|
|
|
|
{
|
|
|
|
length = (20 * settings->MonitorCount) + 16;
|
|
|
|
gcc_write_user_data_header(s, CS_MONITOR_EX, length);
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, 0); /* flags */
|
|
|
|
Stream_Write_UINT32(s, 20); /* monitorAttributeSize */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorCount); /* monitorCount */
|
|
|
|
|
|
|
|
for (i = 0; i < settings->MonitorCount; i++)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorDefArray[i].attributes.physicalWidth); /* physicalWidth */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorDefArray[i].attributes.physicalHeight); /* physicalHeight */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorDefArray[i].attributes.orientation); /* orientation */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorDefArray[i].attributes.desktopScaleFactor); /* desktopScaleFactor */
|
|
|
|
Stream_Write_UINT32(s, settings->MonitorDefArray[i].attributes.deviceScaleFactor); /* deviceScaleFactor */
|
|
|
|
}
|
|
|
|
}
|
2014-01-24 01:00:02 +04:00
|
|
|
}
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
/**
|
|
|
|
* Read a client message channel data block (TS_UD_CS_MCS_MSGCHANNEL).\n
|
|
|
|
* @msdn{jj217627}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_message_channel_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
|
|
|
UINT32 flags;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT32(s, flags);
|
|
|
|
|
2014-10-28 11:06:04 +03:00
|
|
|
mcs->messageChannelId = mcs->baseChannelId++;
|
|
|
|
|
2014-01-24 01:00:02 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
/**
|
|
|
|
* Write a client message channel data block (TS_UD_CS_MCS_MSGCHANNEL).\n
|
|
|
|
* @msdn{jj217627}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_message_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
if (settings->NetworkAutoDetect ||
|
|
|
|
settings->SupportHeartbeatPdu ||
|
|
|
|
settings->SupportMultitransport)
|
|
|
|
{
|
|
|
|
gcc_write_user_data_header(s, CS_MCS_MSGCHANNEL, 8);
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, 0); /* flags */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_message_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
|
|
|
UINT16 MCSChannelId;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
|
|
|
return FALSE;
|
2014-01-26 02:08:43 +04:00
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
Stream_Read_UINT16(s, MCSChannelId); /* MCSChannelId */
|
|
|
|
|
|
|
|
/* Save the MCS message channel id */
|
2014-02-14 02:50:38 +04:00
|
|
|
mcs->messageChannelId = MCSChannelId;
|
2014-01-24 03:01:31 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
BOOL gcc_write_server_message_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
2014-10-28 11:06:04 +03:00
|
|
|
if (mcs->messageChannelId == 0)
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
|
|
|
|
2015-04-07 16:19:59 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 2 + 4))
|
2015-04-01 16:11:57 +03:00
|
|
|
return FALSE;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2014-01-26 02:08:43 +04:00
|
|
|
gcc_write_user_data_header(s, SC_MCS_MSGCHANNEL, 6);
|
|
|
|
|
2014-10-28 11:06:04 +03:00
|
|
|
Stream_Write_UINT16(s, mcs->messageChannelId); /* mcsChannelId (2 bytes) */
|
2015-04-01 16:11:57 +03:00
|
|
|
return TRUE;
|
2014-01-24 01:00:02 +04:00
|
|
|
}
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
/**
|
|
|
|
* Read a client multitransport channel data block (TS_UD_CS_MULTITRANSPORT).\n
|
|
|
|
* @msdn{jj217498}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_client_multitransport_channel_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
|
|
|
UINT32 flags;
|
|
|
|
|
|
|
|
if (blockLength < 4)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT32(s, flags);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
/**
|
|
|
|
* Write a client multitransport channel data block (TS_UD_CS_MULTITRANSPORT).\n
|
|
|
|
* @msdn{jj217498}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings rdp settings
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_client_multitransport_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 01:00:02 +04:00
|
|
|
{
|
2014-02-14 02:50:38 +04:00
|
|
|
rdpSettings* settings = mcs->settings;
|
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
if (settings->MultitransportFlags != 0)
|
|
|
|
{
|
|
|
|
gcc_write_user_data_header(s, CS_MULTITRANSPORT, 8);
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, settings->MultitransportFlags); /* flags */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
BOOL gcc_read_server_multitransport_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
|
|
|
UINT32 flags;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
return FALSE;
|
2014-01-24 01:00:02 +04:00
|
|
|
|
2014-01-24 03:01:31 +04:00
|
|
|
Stream_Read_UINT32(s, flags); /* flags */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
void gcc_write_server_multitransport_channel_data(wStream* s, rdpMcs* mcs)
|
2014-01-24 03:01:31 +04:00
|
|
|
{
|
2014-01-26 02:08:43 +04:00
|
|
|
UINT32 flags = 0;
|
|
|
|
|
|
|
|
gcc_write_user_data_header(s, SC_MULTITRANSPORT, 8);
|
2014-01-24 03:01:31 +04:00
|
|
|
|
2014-01-26 02:08:43 +04:00
|
|
|
Stream_Write_UINT32(s, flags); /* flags (4 bytes) */
|
2014-01-24 01:00:02 +04:00
|
|
|
}
|