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
|
|
|
|
2018-11-20 19:27:47 +03:00
|
|
|
/* Protocol Security Negotiation Protocols
|
|
|
|
* [MS-RDPBCGR] 2.2.1.1.1 RDP Negotiation Request (RDP_NEG_REQ)
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PROTOCOL_RDP 0x00000000
|
|
|
|
#define PROTOCOL_SSL 0x00000001
|
|
|
|
#define PROTOCOL_HYBRID 0x00000002
|
|
|
|
#define PROTOCOL_RDSTLS 0x00000004
|
2018-11-20 19:27:47 +03:00
|
|
|
#define PROTOCOL_HYBRID_EX 0x00000008
|
2023-03-08 04:06:47 +03:00
|
|
|
#define PROTOCOL_RDSAAD 0x00000010
|
2015-02-11 23:38:32 +03:00
|
|
|
|
2019-11-06 17:24:51 +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,
|
2018-10-26 11:37:10 +03:00
|
|
|
HYBRID_REQUIRED_BY_SERVER = 0x00000005,
|
|
|
|
SSL_WITH_USER_AUTH_REQUIRED_BY_SERVER = 0x00000006
|
2011-07-18 07:16:31 +04:00
|
|
|
};
|
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef enum
|
2011-07-01 02:48:48 +04:00
|
|
|
{
|
|
|
|
NEGO_STATE_INITIAL,
|
2023-03-07 13:58:28 +03:00
|
|
|
NEGO_STATE_RDSTLS, /* RDSTLS (TLS implicit) */
|
2023-03-08 04:06:47 +03:00
|
|
|
NEGO_STATE_AAD, /* Azure AD Authentication (TLS implicit) */
|
2023-03-07 13:58:28 +03:00
|
|
|
NEGO_STATE_EXT, /* Extended NLA (NLA + TLS implicit) */
|
|
|
|
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 */
|
2011-07-01 02:48:48 +04:00
|
|
|
NEGO_STATE_FINAL
|
2022-02-14 16:59:22 +03:00
|
|
|
} NEGO_STATE;
|
2011-07-01 02:48:48 +04:00
|
|
|
|
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,
|
2021-11-30 12:01:22 +03:00
|
|
|
TYPE_RDP_NEG_FAILURE = 0x3,
|
|
|
|
TYPE_RDP_CORRELATION_INFO = 0x6
|
2011-07-03 20:42:35 +04:00
|
|
|
};
|
|
|
|
|
2021-11-30 12:01:22 +03:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
EXTENDED_CLIENT_DATA_SUPPORTED = 0x01,
|
|
|
|
DYNVC_GFX_PROTOCOL_SUPPORTED = 0x02,
|
|
|
|
RDP_NEGRSP_RESERVED = 0x04,
|
|
|
|
RESTRICTED_ADMIN_MODE_SUPPORTED = 0x08,
|
|
|
|
REDIRECTED_AUTHENTICATION_MODE_SUPPORTED = 0x10
|
|
|
|
} RdpNegRespFlags;
|
2011-08-18 19:15:28 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PRECONNECTION_PDU_V1_SIZE 16
|
|
|
|
#define PRECONNECTION_PDU_V2_MIN_SIZE (PRECONNECTION_PDU_V1_SIZE + 2)
|
2012-07-25 20:46:43 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PRECONNECTION_PDU_V1 1
|
|
|
|
#define PRECONNECTION_PDU_V2 2
|
2012-10-26 02:38:51 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define RESTRICTED_ADMIN_MODE_REQUIRED 0x01
|
|
|
|
#define REDIRECTED_AUTHENTICATION_MODE_REQUIRED 0x02
|
|
|
|
#define CORRELATION_INFO_PRESENT 0x08
|
2013-11-06 10:51:55 +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 void nego_free(rdpNego* nego);
|
|
|
|
|
2024-01-26 15:09:00 +03:00
|
|
|
WINPR_ATTR_MALLOC(nego_free, 1)
|
|
|
|
FREERDP_LOCAL rdpNego* nego_new(rdpTransport* transport);
|
|
|
|
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_init(rdpNego* nego);
|
2018-11-20 19:03:50 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_set_target(rdpNego* nego, const char* hostname, UINT16 port);
|
2019-11-06 17:24:51 +03:00
|
|
|
FREERDP_LOCAL void nego_set_negotiation_enabled(rdpNego* nego, BOOL NegotiateSecurityLayer);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_restricted_admin_mode_required(rdpNego* nego,
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL RestrictedAdminModeRequired);
|
2023-11-17 12:22:06 +03:00
|
|
|
FREERDP_LOCAL void nego_set_RCG_required(rdpNego* nego, BOOL enabled);
|
|
|
|
FREERDP_LOCAL void nego_set_RCG_supported(rdpNego* nego, BOOL enabled);
|
|
|
|
FREERDP_LOCAL BOOL nego_get_remoteCredentialGuard(rdpNego* nego);
|
2023-09-22 23:13:54 +03:00
|
|
|
FREERDP_LOCAL void nego_set_childsession_enabled(rdpNego* nego, BOOL ChildSessionEnabled);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_set_gateway_enabled(rdpNego* nego, BOOL GatewayEnabled);
|
2019-11-06 17:24:51 +03:00
|
|
|
FREERDP_LOCAL void nego_set_gateway_bypass_local(rdpNego* nego, 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);
|
2023-03-07 13:58:28 +03:00
|
|
|
FREERDP_LOCAL void nego_enable_rdstls(rdpNego* nego, BOOL enable_rdstls);
|
2023-03-08 04:06:47 +03:00
|
|
|
FREERDP_LOCAL void nego_enable_aad(rdpNego* nego, BOOL enable_aad);
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void nego_enable_ext(rdpNego* nego, BOOL enable_ext);
|
2019-05-17 15:32:54 +03:00
|
|
|
FREERDP_LOCAL const BYTE* nego_get_routing_token(rdpNego* nego, DWORD* RoutingTokenLength);
|
2023-06-28 11:28:42 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_set_routing_token(rdpNego* nego, const void* RoutingToken,
|
2019-11-06 17:24:51 +03:00
|
|
|
DWORD RoutingTokenLength);
|
2020-11-18 09:51:45 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_set_cookie(rdpNego* nego, const char* cookie);
|
2019-11-06 17:24:51 +03:00
|
|
|
FREERDP_LOCAL void nego_set_cookie_max_length(rdpNego* nego, UINT32 CookieMaxLength);
|
|
|
|
FREERDP_LOCAL void nego_set_send_preconnection_pdu(rdpNego* nego, BOOL SendPreconnectionPdu);
|
|
|
|
FREERDP_LOCAL void nego_set_preconnection_id(rdpNego* nego, UINT32 PreconnectionId);
|
2020-11-18 09:51:45 +03:00
|
|
|
FREERDP_LOCAL void nego_set_preconnection_blob(rdpNego* nego, const char* PreconnectionBlob);
|
2011-07-01 02:48:48 +04:00
|
|
|
|
2018-11-20 18:38:06 +03:00
|
|
|
FREERDP_LOCAL UINT32 nego_get_selected_protocol(rdpNego* nego);
|
|
|
|
FREERDP_LOCAL BOOL nego_set_selected_protocol(rdpNego* nego, UINT32 SelectedProtocol);
|
|
|
|
|
|
|
|
FREERDP_LOCAL UINT32 nego_get_requested_protocols(rdpNego* nego);
|
|
|
|
FREERDP_LOCAL BOOL nego_set_requested_protocols(rdpNego* nego, UINT32 RequestedProtocols);
|
|
|
|
|
2023-11-28 14:16:58 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_update_settings_from_state(rdpNego* nego, rdpSettings* settings);
|
|
|
|
|
2018-11-20 18:38:06 +03:00
|
|
|
FREERDP_LOCAL BOOL nego_set_state(rdpNego* nego, NEGO_STATE state);
|
|
|
|
FREERDP_LOCAL NEGO_STATE nego_get_state(rdpNego* nego);
|
|
|
|
|
|
|
|
FREERDP_LOCAL SEC_WINNT_AUTH_IDENTITY* nego_get_identity(rdpNego* nego);
|
|
|
|
|
|
|
|
FREERDP_LOCAL void nego_free_nla(rdpNego* nego);
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#endif /* FREERDP_LIB_CORE_NEGO_H */
|