@@ -8,6 +8,7 @@ use ironrdp_connector::{
8
8
use ironrdp_core:: decode;
9
9
use ironrdp_core:: WriteBuf ;
10
10
use ironrdp_pdu as pdu;
11
+ use ironrdp_pdu:: nego:: SecurityProtocol ;
11
12
use ironrdp_pdu:: x224:: X224 ;
12
13
use ironrdp_svc:: { StaticChannelSet , SvcServerProcessor } ;
13
14
use pdu:: rdp:: capability_sets:: CapabilitySet ;
@@ -28,7 +29,7 @@ const USER_CHANNEL_ID: u16 = 1002;
28
29
29
30
pub struct Acceptor {
30
31
pub ( crate ) state : AcceptorState ,
31
- security : nego :: SecurityProtocol ,
32
+ security : SecurityProtocol ,
32
33
io_channel_id : u16 ,
33
34
user_channel_id : u16 ,
34
35
desktop_size : DesktopSize ,
@@ -49,7 +50,7 @@ pub struct AcceptorResult {
49
50
50
51
impl Acceptor {
51
52
pub fn new (
52
- security : nego :: SecurityProtocol ,
53
+ security : SecurityProtocol ,
53
54
desktop_size : DesktopSize ,
54
55
capabilities : Vec < CapabilitySet > ,
55
56
creds : Option < Credentials > ,
@@ -121,7 +122,7 @@ impl Acceptor {
121
122
}
122
123
}
123
124
124
- pub fn reached_security_upgrade ( & self ) -> Option < nego :: SecurityProtocol > {
125
+ pub fn reached_security_upgrade ( & self ) -> Option < SecurityProtocol > {
125
126
match self . state {
126
127
AcceptorState :: SecurityUpgrade { .. } => Some ( self . security ) ,
127
128
_ => None ,
@@ -173,39 +174,39 @@ pub enum AcceptorState {
173
174
174
175
InitiationWaitRequest ,
175
176
InitiationSendConfirm {
176
- requested_protocol : nego :: SecurityProtocol ,
177
+ requested_protocol : SecurityProtocol ,
177
178
} ,
178
179
SecurityUpgrade {
179
- requested_protocol : nego :: SecurityProtocol ,
180
- protocol : nego :: SecurityProtocol ,
180
+ requested_protocol : SecurityProtocol ,
181
+ protocol : SecurityProtocol ,
181
182
} ,
182
183
Credssp {
183
- requested_protocol : nego :: SecurityProtocol ,
184
- protocol : nego :: SecurityProtocol ,
184
+ requested_protocol : SecurityProtocol ,
185
+ protocol : SecurityProtocol ,
185
186
} ,
186
187
BasicSettingsWaitInitial {
187
- requested_protocol : nego :: SecurityProtocol ,
188
- protocol : nego :: SecurityProtocol ,
188
+ requested_protocol : SecurityProtocol ,
189
+ protocol : SecurityProtocol ,
189
190
} ,
190
191
BasicSettingsSendResponse {
191
- requested_protocol : nego :: SecurityProtocol ,
192
- protocol : nego :: SecurityProtocol ,
192
+ requested_protocol : SecurityProtocol ,
193
+ protocol : SecurityProtocol ,
193
194
early_capability : Option < gcc:: ClientEarlyCapabilityFlags > ,
194
195
channels : Vec < ( u16 , Option < gcc:: ChannelDef > ) > ,
195
196
} ,
196
197
ChannelConnection {
197
- protocol : nego :: SecurityProtocol ,
198
+ protocol : SecurityProtocol ,
198
199
early_capability : Option < gcc:: ClientEarlyCapabilityFlags > ,
199
200
channels : Vec < ( u16 , gcc:: ChannelDef ) > ,
200
201
connection : ChannelConnectionSequence ,
201
202
} ,
202
203
RdpSecurityCommencement {
203
- protocol : nego :: SecurityProtocol ,
204
+ protocol : SecurityProtocol ,
204
205
early_capability : Option < gcc:: ClientEarlyCapabilityFlags > ,
205
206
channels : Vec < ( u16 , gcc:: ChannelDef ) > ,
206
207
} ,
207
208
SecureSettingsExchange {
208
- protocol : nego :: SecurityProtocol ,
209
+ protocol : SecurityProtocol ,
209
210
early_capability : Option < gcc:: ClientEarlyCapabilityFlags > ,
210
211
channels : Vec < ( u16 , gcc:: ChannelDef ) > ,
211
212
} ,
@@ -310,7 +311,16 @@ impl Sequence for Acceptor {
310
311
}
311
312
312
313
AcceptorState :: InitiationSendConfirm { requested_protocol } => {
313
- let protocol = requested_protocol & self . security ;
314
+ let protocols = requested_protocol & self . security ;
315
+ let protocol = if protocols. intersects ( SecurityProtocol :: HYBRID_EX ) {
316
+ SecurityProtocol :: HYBRID_EX
317
+ } else if protocols. intersects ( SecurityProtocol :: HYBRID ) {
318
+ SecurityProtocol :: HYBRID
319
+ } else if protocols. intersects ( SecurityProtocol :: SSL ) {
320
+ SecurityProtocol :: SSL
321
+ } else {
322
+ return Err ( ConnectorError :: general ( "failed to negotiate security protocol" ) ) ;
323
+ } ;
314
324
let connection_confirm = nego:: ConnectionConfirm :: Response {
315
325
flags : nego:: ResponseFlags :: empty ( ) ,
316
326
protocol,
@@ -335,18 +345,17 @@ impl Sequence for Acceptor {
335
345
protocol,
336
346
} => {
337
347
debug ! ( ?requested_protocol) ;
338
- let next_state =
339
- if protocol. intersects ( nego:: SecurityProtocol :: HYBRID | nego:: SecurityProtocol :: HYBRID_EX ) {
340
- AcceptorState :: Credssp {
341
- requested_protocol,
342
- protocol,
343
- }
344
- } else {
345
- AcceptorState :: BasicSettingsWaitInitial {
346
- requested_protocol,
347
- protocol,
348
- }
349
- } ;
348
+ let next_state = if protocol. intersects ( SecurityProtocol :: HYBRID | SecurityProtocol :: HYBRID_EX ) {
349
+ AcceptorState :: Credssp {
350
+ requested_protocol,
351
+ protocol,
352
+ }
353
+ } else {
354
+ AcceptorState :: BasicSettingsWaitInitial {
355
+ requested_protocol,
356
+ protocol,
357
+ }
358
+ } ;
350
359
( Written :: Nothing , next_state)
351
360
}
352
361
@@ -521,7 +530,7 @@ impl Sequence for Acceptor {
521
530
522
531
debug ! ( message = ?client_info, "Received" ) ;
523
532
524
- if !protocol. intersects ( nego :: SecurityProtocol :: HYBRID | nego :: SecurityProtocol :: HYBRID_EX ) {
533
+ if !protocol. intersects ( SecurityProtocol :: HYBRID | SecurityProtocol :: HYBRID_EX ) {
525
534
let creds = client_info. client_info . credentials ;
526
535
527
536
if self . creds . as_ref ( ) . map_or ( true , |srv_creds| srv_creds != & creds) {
@@ -706,7 +715,7 @@ impl Sequence for Acceptor {
706
715
fn create_gcc_blocks (
707
716
io_channel : u16 ,
708
717
channel_ids : Vec < u16 > ,
709
- requested : nego :: SecurityProtocol ,
718
+ requested : SecurityProtocol ,
710
719
skip_channel_join : bool ,
711
720
) -> gcc:: ServerGccBlocks {
712
721
gcc:: ServerGccBlocks {
0 commit comments