2011-07-01 02:48:48 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-01 02:48:48 +04:00
|
|
|
* RDP Protocol Security Negotiation
|
|
|
|
*
|
2012-11-01 04:38:48 +04:00
|
|
|
* Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2011-07-01 02:48:48 +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.
|
|
|
|
*/
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#ifndef FREERDP_LIB_CORE_NEGO_H
|
|
|
|
#define FREERDP_LIB_CORE_NEGO_H
|
2011-07-01 02:48:48 +04:00
|
|
|
|
2011-07-03 20:42:35 +04:00
|
|
|
#include "transport.h"
|
2013-03-22 00:45:25 +04:00
|
|
|
|
2011-07-07 21:37:48 +04:00
|
|
|
#include <freerdp/types.h>
|
|
|
|
#include <freerdp/settings.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2016-08-10 10:12:55 +03:00
|
|
|
#include <freerdp/api.h>
|
2013-03-22 00:45:25 +04:00
|
|
|
|
|
|
|
#include <winpr/stream.h>
|
2011-07-01 02:48:48 +04:00
|
|
|
|
2011-07-18 07:16:31 +04:00
|
|
|
/* Protocol Security Negotiation Protocols */
|
2017-02-20 20:31:58 +03:00
|
|
|
#define PROTOCOL_RDP 0x00000000
|
|
|
|
#define PROTOCOL_TLS 0x00000001
|
|
|
|
#define PROTOCOL_NLA 0x00000002
|
|
|
|
#define PROTOCOL_EXT 0x00000008
|
2015-02-11 23:38:32 +03:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
#define PROTOCOL_FAILED_NEGO 0x80000000 /* only used internally, not on the wire */
|
2011-07-18 07:16:31 +04:00
|
|
|
|
|
|
|
/* Protocol Security Negotiation Failure Codes */
|
|
|
|
enum RDP_NEG_FAILURE_FAILURECODES
|
|
|
|
{
|
|
|
|
SSL_REQUIRED_BY_SERVER = 0x00000001,
|
|
|
|
SSL_NOT_ALLOWED_BY_SERVER = 0x00000002,
|
|
|
|
SSL_CERT_NOT_ON_SERVER = 0x00000003,
|
|
|
|
INCONSISTENT_FLAGS = 0x00000004,
|
|
|
|
HYBRID_REQUIRED_BY_SERVER = 0x00000005
|
|
|
|
};
|
|
|
|
|
2012-11-01 04:38:48 +04:00
|
|
|
/* Authorization Result */
|
|
|
|
#define AUTHZ_SUCCESS 0x00000000
|
|
|
|
#define AUTHZ_ACCESS_DENIED 0x0000052E
|
|
|
|
|
2011-07-01 02:48:48 +04:00
|
|
|
enum _NEGO_STATE
|
|
|
|
{
|
|
|
|
NEGO_STATE_INITIAL,
|
2012-11-01 04:38:48 +04:00
|
|
|
NEGO_STATE_EXT, /* Extended NLA (NLA + TLS implicit) */
|
2011-07-01 02:48:48 +04:00
|
|
|
NEGO_STATE_NLA, /* Network Level Authentication (TLS implicit) */
|
|
|
|
NEGO_STATE_TLS, /* TLS Encryption without NLA */
|
|
|
|
NEGO_STATE_RDP, /* Standard Legacy RDP Encryption */
|
|
|
|
NEGO_STATE_FAIL, /* Negotiation failure */
|
|
|
|
NEGO_STATE_FINAL
|
|
|
|
};
|
|
|
|
typedef enum _NEGO_STATE NEGO_STATE;
|
|
|
|
|
2011-07-03 20:42:35 +04:00
|
|
|
/* RDP Negotiation Messages */
|
|
|
|
enum RDP_NEG_MSG
|
|
|
|
{
|
|
|
|
/* X224_TPDU_CONNECTION_REQUEST */
|
|
|
|
TYPE_RDP_NEG_REQ = 0x1,
|
|
|
|
/* X224_TPDU_CONNECTION_CONFIRM */
|
|
|
|
TYPE_RDP_NEG_RSP = 0x2,
|
|
|
|
TYPE_RDP_NEG_FAILURE = 0x3
|
|
|
|
};
|
|
|
|
|
2012-10-26 02:38:51 +04:00
|
|
|
#define EXTENDED_CLIENT_DATA_SUPPORTED 0x01
|
2012-12-13 23:38:02 +04:00
|
|
|
#define DYNVC_GFX_PROTOCOL_SUPPORTED 0x02
|
|
|
|
#define RDP_NEGRSP_RESERVED 0x04
|
2013-10-22 07:33:25 +04:00
|
|
|
#define RESTRICTED_ADMIN_MODE_SUPPORTED 0x08
|
2011-08-18 19:15:28 +04:00
|
|
|
|
2012-11-01 04:38:48 +04:00
|
|
|
#define PRECONNECTION_PDU_V1_SIZE 16
|
2012-10-26 02:38:51 +04:00
|
|
|
#define PRECONNECTION_PDU_V2_MIN_SIZE (PRECONNECTION_PDU_V1_SIZE + 2)
|
2012-07-25 20:46:43 +04:00
|
|
|
|
2012-11-01 04:38:48 +04:00
|
|
|
#define PRECONNECTION_PDU_V1 1
|
|
|
|
#define PRECONNECTION_PDU_V2 2
|
2012-10-26 02:38:51 +04:00
|
|
|
|
2013-11-06 10:51:55 +04:00
|
|
|
#define RESTRICTED_ADMIN_MODE_REQUIRED 0x01
|
|
|
|
#define CORRELATION_INFO_PRESENT 0x08
|
|
|
|
|
2011-07-03 20:42:35 +04:00
|
|
|
struct rdp_nego
|
2011-07-01 02:48:48 +04:00
|
|
|
{
|
|
|
|
int port;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 flags;
|
2011-07-03 20:42:35 +04:00
|
|
|
char* hostname;
|
2011-07-07 21:37:48 +04:00
|
|
|
char* cookie;
|
2012-09-24 12:40:32 +04:00
|
|
|
BYTE* RoutingToken;
|
|
|
|
DWORD RoutingTokenLength;
|
2015-02-03 01:16:32 +03:00
|
|
|
BOOL SendPreconnectionPdu;
|
|
|
|
UINT32 PreconnectionId;
|
|
|
|
char* PreconnectionBlob;
|
2012-07-25 20:46:43 +04:00
|
|
|
|
2011-07-01 02:48:48 +04:00
|
|
|
NEGO_STATE state;
|
2015-02-03 01:16:32 +03:00
|
|
|
BOOL TcpConnected;
|
|
|
|
BOOL SecurityConnected;
|
|
|
|
UINT32 CookieMaxLength;
|
2012-07-25 20:46:43 +04:00
|
|
|
|
2013-04-13 02:03:56 +04:00
|
|
|
BOOL sendNegoData;
|
2015-02-03 01:16:32 +03:00
|
|
|
UINT32 SelectedProtocol;
|
|
|
|
UINT32 RequestedProtocols;
|
2013-01-10 20:19:57 +04:00
|
|
|
BOOL NegotiateSecurityLayer;
|
2015-02-03 01:16:32 +03:00
|
|
|
BYTE EnabledProtocols[16];
|
2013-11-06 10:51:55 +04:00
|
|
|
BOOL RestrictedAdminModeRequired;
|
2014-03-24 22:44:18 +04:00
|
|
|
BOOL GatewayEnabled;
|
|
|
|
BOOL GatewayBypassLocal;
|
2012-07-25 20:46:43 +04:00
|
|
|
|
2011-07-07 21:37:48 +04:00
|
|
|
rdpTransport* transport;
|
2011-07-01 02:48:48 +04:00
|
|
|
};
|
2011-07-03 20:42:35 +04:00
|
|
|
typedef struct rdp_nego rdpNego;
|
|
|
|
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_connect(rdpNego* nego);
|
|
|
|
FREERDP_LOCAL BOOL nego_disconnect(rdpNego* nego);
|
|
|
|
|
|
|
|
FREERDP_LOCAL int nego_recv(rdpTransport* transport, wStream* s, void* extra);
|
|
|
|
FREERDP_LOCAL BOOL nego_read_request(rdpNego* nego, wStream* s);
|
|
|
|
|
|
|
|
FREERDP_LOCAL BOOL nego_send_negotiation_request(rdpNego* nego);
|
|
|
|
FREERDP_LOCAL BOOL nego_send_negotiation_response(rdpNego* nego);
|
|
|
|
|
|
|
|
FREERDP_LOCAL rdpNego* nego_new(rdpTransport* transport);
|
|
|
|
FREERDP_LOCAL void nego_free(rdpNego* nego);
|
|
|
|
|
|
|
|
FREERDP_LOCAL void nego_init(rdpNego* nego);
|
|
|
|
FREERDP_LOCAL void nego_set_target(rdpNego* nego, char* hostname, int port);
|
|
|
|
FREERDP_LOCAL void nego_set_negotiation_enabled(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
BOOL NegotiateSecurityLayer);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_restricted_admin_mode_required(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
BOOL RestrictedAdminModeRequired);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_gateway_enabled(rdpNego* nego, BOOL GatewayEnabled);
|
|
|
|
FREERDP_LOCAL void nego_set_gateway_bypass_local(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
BOOL GatewayBypassLocal);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_enable_rdp(rdpNego* nego, BOOL enable_rdp);
|
|
|
|
FREERDP_LOCAL void nego_enable_tls(rdpNego* nego, BOOL enable_tls);
|
|
|
|
FREERDP_LOCAL void nego_enable_nla(rdpNego* nego, BOOL enable_nla);
|
|
|
|
FREERDP_LOCAL void nego_enable_ext(rdpNego* nego, BOOL enable_ext);
|
|
|
|
FREERDP_LOCAL BOOL nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken,
|
2017-02-20 20:31:58 +03:00
|
|
|
DWORD RoutingTokenLength);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_set_cookie(rdpNego* nego, char* cookie);
|
|
|
|
FREERDP_LOCAL void nego_set_cookie_max_length(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
UINT32 CookieMaxLength);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_send_preconnection_pdu(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
BOOL SendPreconnectionPdu);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_preconnection_id(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
UINT32 PreconnectionId);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_preconnection_blob(rdpNego* nego,
|
2017-02-20 20:31:58 +03:00
|
|
|
char* PreconnectionBlob);
|
2011-07-01 02:48:48 +04:00
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#endif /* FREERDP_LIB_CORE_NEGO_H */
|