/src/FreeRDP/libfreerdp/core/fastpath.c
Line | Count | Source |
1 | | /** |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * Fast Path |
4 | | * |
5 | | * Copyright 2011 Vic Lee |
6 | | * Copyright 2014 Norbert Federa <norbert.federa@thincast.com> |
7 | | * Copyright 2017 Armin Novak <armin.novak@thincast.com> |
8 | | * Copyright 2017 Thincast Technologies GmbH |
9 | | * |
10 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
11 | | * you may not use this file except in compliance with the License. |
12 | | * You may obtain a copy of the License at |
13 | | * |
14 | | * http://www.apache.org/licenses/LICENSE-2.0 |
15 | | * |
16 | | * Unless required by applicable law or agreed to in writing, software |
17 | | * distributed under the License is distributed on an "AS IS" BASIS, |
18 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 | | * See the License for the specific language governing permissions and |
20 | | * limitations under the License. |
21 | | */ |
22 | | |
23 | | #include <freerdp/config.h> |
24 | | |
25 | | #include "settings.h" |
26 | | |
27 | | #include <stdio.h> |
28 | | #include <stdlib.h> |
29 | | #include <string.h> |
30 | | |
31 | | #include <winpr/crt.h> |
32 | | #include <winpr/assert.h> |
33 | | #include <winpr/stream.h> |
34 | | |
35 | | #include <freerdp/api.h> |
36 | | #include <freerdp/log.h> |
37 | | #include <freerdp/crypto/per.h> |
38 | | |
39 | | #include "orders.h" |
40 | | #include "update.h" |
41 | | #include "surface.h" |
42 | | #include "fastpath.h" |
43 | | #include "rdp.h" |
44 | | |
45 | | #include "../cache/pointer.h" |
46 | | #include "../cache/palette.h" |
47 | | #include "../cache/bitmap.h" |
48 | | |
49 | | #define TAG FREERDP_TAG("core.fastpath") |
50 | | |
51 | | enum FASTPATH_INPUT_ENCRYPTION_FLAGS |
52 | | { |
53 | | FASTPATH_INPUT_SECURE_CHECKSUM = 0x1, |
54 | | FASTPATH_INPUT_ENCRYPTED = 0x2 |
55 | | }; |
56 | | |
57 | | enum FASTPATH_OUTPUT_ENCRYPTION_FLAGS |
58 | | { |
59 | | FASTPATH_OUTPUT_SECURE_CHECKSUM = 0x1, |
60 | | FASTPATH_OUTPUT_ENCRYPTED = 0x2 |
61 | | }; |
62 | | |
63 | | struct rdp_fastpath |
64 | | { |
65 | | rdpRdp* rdp; |
66 | | wStream* fs; |
67 | | BYTE encryptionFlags; |
68 | | BYTE numberEvents; |
69 | | wStream* updateData; |
70 | | int fragmentation; |
71 | | }; |
72 | | |
73 | | /** |
74 | | * Fast-Path packet format is defined in [MS-RDPBCGR] 2.2.9.1.2, which revises |
75 | | * server output packets from the first byte with the goal of improving |
76 | | * bandwidth. |
77 | | * |
78 | | * Slow-Path packet always starts with TPKT header, which has the first |
79 | | * byte 0x03, while Fast-Path packet starts with 2 zero bits in the first |
80 | | * two less significant bits of the first byte. |
81 | | */ |
82 | | |
83 | | static const char* const FASTPATH_UPDATETYPE_STRINGS[] = { |
84 | | "Orders", /* 0x0 */ |
85 | | "Bitmap", /* 0x1 */ |
86 | | "Palette", /* 0x2 */ |
87 | | "Synchronize", /* 0x3 */ |
88 | | "Surface Commands", /* 0x4 */ |
89 | | "System Pointer Hidden", /* 0x5 */ |
90 | | "System Pointer Default", /* 0x6 */ |
91 | | "???", /* 0x7 */ |
92 | | "Pointer Position", /* 0x8 */ |
93 | | "Color Pointer", /* 0x9 */ |
94 | | "Cached Pointer", /* 0xA */ |
95 | | "New Pointer", /* 0xB */ |
96 | | }; |
97 | | |
98 | | static const char* fastpath_update_to_string(UINT8 update) |
99 | 8.77k | { |
100 | 8.77k | if (update >= ARRAYSIZE(FASTPATH_UPDATETYPE_STRINGS)) |
101 | 498 | return "UNKNOWN"; |
102 | | |
103 | 8.27k | return FASTPATH_UPDATETYPE_STRINGS[update]; |
104 | 8.77k | } |
105 | | |
106 | | static BOOL fastpath_read_update_header(wStream* s, BYTE* updateCode, BYTE* fragmentation, |
107 | | BYTE* compression) |
108 | 41.0k | { |
109 | 41.0k | BYTE updateHeader = 0; |
110 | | |
111 | 41.0k | if (!s || !updateCode || !fragmentation || !compression) |
112 | 0 | return FALSE; |
113 | | |
114 | 41.0k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
115 | 0 | return FALSE; |
116 | | |
117 | 41.0k | Stream_Read_UINT8(s, updateHeader); |
118 | 41.0k | *updateCode = updateHeader & 0x0F; |
119 | 41.0k | *fragmentation = (updateHeader >> 4) & 0x03; |
120 | 41.0k | *compression = (updateHeader >> 6) & 0x03; |
121 | 41.0k | return TRUE; |
122 | 41.0k | } |
123 | | |
124 | | static BOOL fastpath_write_update_header(wStream* s, const FASTPATH_UPDATE_HEADER* fpUpdateHeader) |
125 | 127 | { |
126 | 127 | BYTE updateHeader = 0; |
127 | 127 | WINPR_ASSERT(fpUpdateHeader); |
128 | | |
129 | 127 | updateHeader |= fpUpdateHeader->updateCode & 0x0F; |
130 | 127 | updateHeader |= (fpUpdateHeader->fragmentation & 0x03) << 4; |
131 | 127 | updateHeader |= (fpUpdateHeader->compression & 0x03) << 6; |
132 | | |
133 | 127 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 1)) |
134 | 0 | return FALSE; |
135 | 127 | Stream_Write_UINT8(s, updateHeader); |
136 | | |
137 | 127 | if (fpUpdateHeader->compression) |
138 | 0 | { |
139 | 0 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 1)) |
140 | 0 | return FALSE; |
141 | | |
142 | 0 | Stream_Write_UINT8(s, fpUpdateHeader->compressionFlags); |
143 | 0 | } |
144 | | |
145 | 127 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 2)) |
146 | 0 | return FALSE; |
147 | | |
148 | 127 | Stream_Write_UINT16(s, fpUpdateHeader->size); |
149 | 127 | return TRUE; |
150 | 127 | } |
151 | | |
152 | | static UINT32 fastpath_get_update_header_size(FASTPATH_UPDATE_HEADER* fpUpdateHeader) |
153 | 127 | { |
154 | 127 | WINPR_ASSERT(fpUpdateHeader); |
155 | 127 | return (fpUpdateHeader->compression) ? 4 : 3; |
156 | 127 | } |
157 | | |
158 | | static BOOL fastpath_write_update_pdu_header(wStream* s, |
159 | | const FASTPATH_UPDATE_PDU_HEADER* fpUpdatePduHeader, |
160 | | rdpRdp* rdp) |
161 | 127 | { |
162 | 127 | BYTE fpOutputHeader = 0; |
163 | 127 | WINPR_ASSERT(fpUpdatePduHeader); |
164 | 127 | WINPR_ASSERT(rdp); |
165 | | |
166 | 127 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 3)) |
167 | 0 | return FALSE; |
168 | | |
169 | 127 | fpOutputHeader |= (fpUpdatePduHeader->action & 0x03); |
170 | 127 | fpOutputHeader |= (fpUpdatePduHeader->secFlags & 0x03) << 6; |
171 | 127 | Stream_Write_UINT8(s, fpOutputHeader); /* fpOutputHeader (1 byte) */ |
172 | 127 | Stream_Write_UINT8(s, 0x80 | (fpUpdatePduHeader->length >> 8)); /* length1 */ |
173 | 127 | Stream_Write_UINT8(s, fpUpdatePduHeader->length & 0xFF); /* length2 */ |
174 | | |
175 | 127 | if (fpUpdatePduHeader->secFlags) |
176 | 0 | { |
177 | 0 | WINPR_ASSERT(rdp->settings); |
178 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
179 | 0 | ENCRYPTION_METHOD_FIPS) |
180 | 0 | { |
181 | 0 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 4)) |
182 | 0 | return FALSE; |
183 | | |
184 | 0 | Stream_Write(s, fpUpdatePduHeader->fipsInformation, 4); |
185 | 0 | } |
186 | | |
187 | 0 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 8)) |
188 | 0 | return FALSE; |
189 | | |
190 | 0 | Stream_Write(s, fpUpdatePduHeader->dataSignature, 8); |
191 | 0 | } |
192 | | |
193 | 127 | return TRUE; |
194 | 127 | } |
195 | | |
196 | | static UINT32 fastpath_get_update_pdu_header_size(FASTPATH_UPDATE_PDU_HEADER* fpUpdatePduHeader, |
197 | | rdpRdp* rdp) |
198 | 127 | { |
199 | 127 | UINT32 size = 3; /* fpUpdatePduHeader + length1 + length2 */ |
200 | | |
201 | 127 | if (!fpUpdatePduHeader || !rdp) |
202 | 0 | return 0; |
203 | | |
204 | 127 | if (fpUpdatePduHeader->secFlags) |
205 | 0 | { |
206 | 0 | size += 8; /* dataSignature */ |
207 | |
|
208 | 0 | WINPR_ASSERT(rdp->settings); |
209 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
210 | 0 | ENCRYPTION_METHOD_FIPS) |
211 | 0 | size += 4; /* fipsInformation */ |
212 | 0 | } |
213 | | |
214 | 127 | return size; |
215 | 127 | } |
216 | | |
217 | | BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16* length) |
218 | 17.7k | { |
219 | 17.7k | BYTE header = 0; |
220 | | |
221 | 17.7k | if (!s || !length) |
222 | 0 | return FALSE; |
223 | | |
224 | 17.7k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
225 | 5.73k | return FALSE; |
226 | | |
227 | 12.0k | Stream_Read_UINT8(s, header); |
228 | | |
229 | 12.0k | if (fastpath) |
230 | 12.0k | { |
231 | 12.0k | fastpath->encryptionFlags = (header & 0xC0) >> 6; |
232 | 12.0k | fastpath->numberEvents = (header & 0x3C) >> 2; |
233 | 12.0k | } |
234 | | |
235 | 12.0k | if (!per_read_length(s, length)) |
236 | 178 | return FALSE; |
237 | | |
238 | 11.8k | const size_t pos = Stream_GetPosition(s); |
239 | 11.8k | if (pos > *length) |
240 | 8.21k | return FALSE; |
241 | | |
242 | 3.62k | *length = *length - (UINT16)pos; |
243 | 3.62k | return TRUE; |
244 | 11.8k | } |
245 | | |
246 | | static BOOL fastpath_recv_orders(rdpUpdate* update, wStream* s) |
247 | 8.70k | { |
248 | 8.70k | UINT16 numberOrders = 0; |
249 | | |
250 | 8.70k | if (!s) |
251 | 0 | { |
252 | 0 | WLog_ERR(TAG, "Invalid arguments"); |
253 | 0 | return FALSE; |
254 | 0 | } |
255 | | |
256 | 8.70k | if (!update) |
257 | 0 | { |
258 | 0 | WLog_ERR(TAG, "Invalid configuration"); |
259 | 0 | return FALSE; |
260 | 0 | } |
261 | | |
262 | 8.70k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) |
263 | 1.74k | return FALSE; |
264 | | |
265 | 6.95k | Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ |
266 | | |
267 | 240k | while (numberOrders > 0) |
268 | 235k | { |
269 | 235k | if (!update_recv_order(update, s)) |
270 | 2.58k | return FALSE; |
271 | | |
272 | 233k | numberOrders--; |
273 | 233k | } |
274 | | |
275 | 4.36k | return TRUE; |
276 | 6.95k | } |
277 | | |
278 | | static BOOL fastpath_recv_update_common(rdpUpdate* update, wStream* s) |
279 | 1.26k | { |
280 | 1.26k | BOOL rc = FALSE; |
281 | 1.26k | UINT16 updateType = 0; |
282 | 1.26k | BOOL defaultReturn = 0; |
283 | | |
284 | 1.26k | if (!s) |
285 | 0 | return FALSE; |
286 | | |
287 | 1.26k | if (!update || !update->context) |
288 | 0 | return FALSE; |
289 | | |
290 | 1.26k | rdpContext* context = update->context; |
291 | | |
292 | 1.26k | defaultReturn = freerdp_settings_get_bool(context->settings, FreeRDP_DeactivateClientDecoding); |
293 | | |
294 | 1.26k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) |
295 | 656 | return FALSE; |
296 | | |
297 | 611 | Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ |
298 | 611 | switch (updateType) |
299 | 611 | { |
300 | 280 | case UPDATE_TYPE_BITMAP: |
301 | 280 | { |
302 | 280 | BITMAP_UPDATE* bitmap_update = update_read_bitmap_update(update, s); |
303 | | |
304 | 280 | if (!bitmap_update) |
305 | 138 | return FALSE; |
306 | | |
307 | 142 | rc = IFCALLRESULT(defaultReturn, update->BitmapUpdate, context, bitmap_update); |
308 | 142 | free_bitmap_update(context, bitmap_update); |
309 | 142 | } |
310 | 0 | break; |
311 | | |
312 | 201 | case UPDATE_TYPE_PALETTE: |
313 | 201 | { |
314 | 201 | PALETTE_UPDATE* palette_update = update_read_palette(update, s); |
315 | | |
316 | 201 | if (!palette_update) |
317 | 153 | return FALSE; |
318 | | |
319 | 48 | rc = IFCALLRESULT(defaultReturn, update->Palette, context, palette_update); |
320 | 48 | free_palette_update(context, palette_update); |
321 | 48 | } |
322 | 0 | break; |
323 | | |
324 | 130 | default: |
325 | 130 | break; |
326 | 611 | } |
327 | | |
328 | 320 | return rc; |
329 | 611 | } |
330 | | |
331 | | static BOOL fastpath_recv_update_synchronize(WINPR_ATTR_UNUSED rdpFastPath* fastpath, wStream* s) |
332 | 4.24k | { |
333 | | /* server 2008 can send invalid synchronize packet with missing padding, |
334 | | so don't return FALSE even if the packet is invalid */ |
335 | 4.24k | WINPR_ASSERT(fastpath); |
336 | 4.24k | WINPR_ASSERT(s); |
337 | | |
338 | 4.24k | const size_t len = Stream_GetRemainingLength(s); |
339 | 4.24k | const size_t skip = MIN(2, len); |
340 | 4.24k | return Stream_SafeSeek(s, skip); /* size (2 bytes), MUST be set to zero */ |
341 | 4.24k | } |
342 | | |
343 | | static BOOL fastpath_recv_update_paint_block(rdpUpdate* update, wStream* s, |
344 | | BOOL (*fkt)(rdpUpdate*, wStream*)) |
345 | 24.1k | { |
346 | 24.1k | WINPR_ASSERT(fkt); |
347 | 24.1k | if (!update_begin_paint(update)) |
348 | 0 | return FALSE; |
349 | | |
350 | 24.1k | BOOL res = fkt(update, s); |
351 | 24.1k | if (!update_end_paint(update)) |
352 | 661 | return FALSE; |
353 | 23.5k | return res; |
354 | 24.1k | } |
355 | | |
356 | | static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, wStream* s) |
357 | 29.8k | { |
358 | 29.8k | BOOL rc = FALSE; |
359 | 29.8k | int status = 0; |
360 | | |
361 | 29.8k | if (!fastpath || !fastpath->rdp || !s) |
362 | 0 | return -1; |
363 | | |
364 | 29.8k | Stream_SealLength(s); |
365 | 29.8k | Stream_ResetPosition(s); |
366 | | |
367 | 29.8k | rdpUpdate* update = fastpath->rdp->update; |
368 | | |
369 | 29.8k | if (!update || !update->pointer || !update->context) |
370 | 0 | return -1; |
371 | | |
372 | 29.8k | rdpContext* context = update->context; |
373 | 29.8k | WINPR_ASSERT(context); |
374 | | |
375 | 29.8k | rdpPointerUpdate* pointer = update->pointer; |
376 | 29.8k | WINPR_ASSERT(pointer); |
377 | | |
378 | | #ifdef WITH_DEBUG_RDP |
379 | | DEBUG_RDP(fastpath->rdp, "recv Fast-Path %s Update (0x%02" PRIX8 "), length:%" PRIuz "", |
380 | | fastpath_update_to_string(updateCode), updateCode, Stream_GetRemainingLength(s)); |
381 | | #endif |
382 | | |
383 | 29.8k | const BOOL defaultReturn = |
384 | 29.8k | freerdp_settings_get_bool(context->settings, FreeRDP_DeactivateClientDecoding); |
385 | 29.8k | switch (updateCode) |
386 | 29.8k | { |
387 | 8.70k | case FASTPATH_UPDATETYPE_ORDERS: |
388 | 8.70k | rc = fastpath_recv_update_paint_block(update, s, fastpath_recv_orders); |
389 | 8.70k | break; |
390 | | |
391 | 985 | case FASTPATH_UPDATETYPE_BITMAP: |
392 | 1.26k | case FASTPATH_UPDATETYPE_PALETTE: |
393 | 1.26k | rc = fastpath_recv_update_paint_block(update, s, fastpath_recv_update_common); |
394 | 1.26k | break; |
395 | | |
396 | 4.24k | case FASTPATH_UPDATETYPE_SYNCHRONIZE: |
397 | 4.24k | if (!fastpath_recv_update_synchronize(fastpath, s)) |
398 | 0 | WLog_ERR(TAG, "fastpath_recv_update_synchronize failure but we continue"); |
399 | 4.24k | else |
400 | 4.24k | rc = IFCALLRESULT(TRUE, update->Synchronize, context); |
401 | | |
402 | 4.24k | break; |
403 | | |
404 | 14.2k | case FASTPATH_UPDATETYPE_SURFCMDS: |
405 | 14.2k | status = fastpath_recv_update_paint_block(update, s, update_recv_surfcmds); |
406 | 14.2k | rc = (status >= 0); |
407 | 14.2k | break; |
408 | | |
409 | 70 | case FASTPATH_UPDATETYPE_PTR_NULL: |
410 | 70 | { |
411 | 70 | POINTER_SYSTEM_UPDATE pointer_system = WINPR_C_ARRAY_INIT; |
412 | 70 | pointer_system.type = SYSPTR_NULL; |
413 | 70 | rc = IFCALLRESULT(defaultReturn, pointer->PointerSystem, context, &pointer_system); |
414 | 70 | } |
415 | 70 | break; |
416 | | |
417 | 91 | case FASTPATH_UPDATETYPE_PTR_DEFAULT: |
418 | 91 | { |
419 | 91 | POINTER_SYSTEM_UPDATE pointer_system = WINPR_C_ARRAY_INIT; |
420 | 91 | pointer_system.type = SYSPTR_DEFAULT; |
421 | 91 | rc = IFCALLRESULT(defaultReturn, pointer->PointerSystem, context, &pointer_system); |
422 | 91 | } |
423 | 91 | break; |
424 | | |
425 | 158 | case FASTPATH_UPDATETYPE_PTR_POSITION: |
426 | 158 | { |
427 | 158 | POINTER_POSITION_UPDATE* pointer_position = update_read_pointer_position(update, s); |
428 | | |
429 | 158 | if (pointer_position) |
430 | 82 | { |
431 | 82 | rc = IFCALLRESULT(defaultReturn, pointer->PointerPosition, context, |
432 | 82 | pointer_position); |
433 | 82 | free_pointer_position_update(context, pointer_position); |
434 | 82 | } |
435 | 158 | } |
436 | 158 | break; |
437 | | |
438 | 268 | case FASTPATH_UPDATETYPE_COLOR: |
439 | 268 | { |
440 | 268 | POINTER_COLOR_UPDATE* pointer_color = update_read_pointer_color(update, s, 24); |
441 | | |
442 | 268 | if (pointer_color) |
443 | 118 | { |
444 | 118 | rc = IFCALLRESULT(defaultReturn, pointer->PointerColor, context, pointer_color); |
445 | 118 | free_pointer_color_update(context, pointer_color); |
446 | 118 | } |
447 | 268 | } |
448 | 268 | break; |
449 | | |
450 | 156 | case FASTPATH_UPDATETYPE_CACHED: |
451 | 156 | { |
452 | 156 | POINTER_CACHED_UPDATE* pointer_cached = update_read_pointer_cached(update, s); |
453 | | |
454 | 156 | if (pointer_cached) |
455 | 49 | { |
456 | 49 | rc = IFCALLRESULT(defaultReturn, pointer->PointerCached, context, pointer_cached); |
457 | 49 | free_pointer_cached_update(context, pointer_cached); |
458 | 49 | } |
459 | 156 | } |
460 | 156 | break; |
461 | | |
462 | 105 | case FASTPATH_UPDATETYPE_POINTER: |
463 | 105 | { |
464 | 105 | POINTER_NEW_UPDATE* pointer_new = update_read_pointer_new(update, s); |
465 | | |
466 | 105 | if (pointer_new) |
467 | 20 | { |
468 | 20 | rc = IFCALLRESULT(defaultReturn, pointer->PointerNew, context, pointer_new); |
469 | 20 | free_pointer_new_update(context, pointer_new); |
470 | 20 | } |
471 | 105 | } |
472 | 105 | break; |
473 | | |
474 | 464 | case FASTPATH_UPDATETYPE_LARGE_POINTER: |
475 | 464 | { |
476 | 464 | POINTER_LARGE_UPDATE* pointer_large = update_read_pointer_large(update, s); |
477 | | |
478 | 464 | if (pointer_large) |
479 | 157 | { |
480 | 157 | rc = IFCALLRESULT(defaultReturn, pointer->PointerLarge, context, pointer_large); |
481 | 157 | free_pointer_large_update(context, pointer_large); |
482 | 157 | } |
483 | 464 | } |
484 | 464 | break; |
485 | 52 | default: |
486 | 52 | break; |
487 | 29.8k | } |
488 | | |
489 | 29.8k | Stream_ResetPosition(s); |
490 | 29.8k | if (!rc) |
491 | 8.77k | { |
492 | 8.77k | WLog_ERR(TAG, "Fastpath update %s [%" PRIx8 "] failed, status %d", |
493 | 8.77k | fastpath_update_to_string(updateCode), updateCode, status); |
494 | 8.77k | return -1; |
495 | 8.77k | } |
496 | | |
497 | 21.0k | return status; |
498 | 29.8k | } |
499 | | |
500 | | static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) |
501 | 41.0k | { |
502 | 41.0k | int status = 0; |
503 | 41.0k | UINT16 size = 0; |
504 | 41.0k | BYTE updateCode = 0; |
505 | 41.0k | BYTE fragmentation = 0; |
506 | 41.0k | BYTE compression = 0; |
507 | 41.0k | BYTE compressionFlags = 0; |
508 | 41.0k | UINT32 DstSize = 0; |
509 | 41.0k | const BYTE* pDstData = nullptr; |
510 | | |
511 | 41.0k | if (!fastpath || !s) |
512 | 0 | return -1; |
513 | | |
514 | 41.0k | rdpRdp* rdp = fastpath->rdp; |
515 | | |
516 | 41.0k | if (!rdp) |
517 | 0 | return -1; |
518 | | |
519 | 41.0k | rdpTransport* transport = rdp->transport; |
520 | | |
521 | 41.0k | if (!transport) |
522 | 0 | return -1; |
523 | | |
524 | 41.0k | if (!fastpath_read_update_header(s, &updateCode, &fragmentation, &compression)) |
525 | 0 | return -1; |
526 | | |
527 | 41.0k | if (compression == FASTPATH_OUTPUT_COMPRESSION_USED) |
528 | 14.3k | { |
529 | 14.3k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
530 | 0 | return -1; |
531 | | |
532 | 14.3k | Stream_Read_UINT8(s, compressionFlags); |
533 | 14.3k | } |
534 | 26.7k | else |
535 | 26.7k | compressionFlags = 0; |
536 | | |
537 | 41.0k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) |
538 | 26 | return -1; |
539 | | |
540 | 41.0k | Stream_Read_UINT16(s, size); |
541 | | |
542 | 41.0k | if (!Stream_CheckAndLogRequiredLength(TAG, s, size)) |
543 | 5.85k | return -1; |
544 | | |
545 | 35.2k | const int bulkStatus = |
546 | 35.2k | bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags); |
547 | 35.2k | Stream_Seek(s, size); |
548 | | |
549 | 35.2k | if (bulkStatus < 0) |
550 | 1.38k | { |
551 | 1.38k | WLog_ERR(TAG, "bulk_decompress() failed"); |
552 | 1.38k | return -1; |
553 | 1.38k | } |
554 | | |
555 | 33.8k | if (!Stream_EnsureRemainingCapacity(fastpath->updateData, DstSize)) |
556 | 0 | return -1; |
557 | | |
558 | 33.8k | Stream_Write(fastpath->updateData, pDstData, DstSize); |
559 | | |
560 | 33.8k | if (fragmentation == FASTPATH_FRAGMENT_SINGLE) |
561 | 28.5k | { |
562 | 28.5k | if (fastpath->fragmentation != -1) |
563 | 28 | { |
564 | 28 | WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_SINGLE"); |
565 | 28 | goto out_fail; |
566 | 28 | } |
567 | | |
568 | 28.4k | status = fastpath_recv_update(fastpath, updateCode, fastpath->updateData); |
569 | | |
570 | 28.4k | if (status < 0) |
571 | 8.76k | { |
572 | 8.76k | WLog_ERR(TAG, "fastpath_recv_update() - %i", status); |
573 | 8.76k | goto out_fail; |
574 | 8.76k | } |
575 | 28.4k | } |
576 | 5.30k | else |
577 | 5.30k | { |
578 | 5.30k | rdpContext* context = nullptr; |
579 | 5.30k | const size_t totalSize = Stream_GetPosition(fastpath->updateData); |
580 | | |
581 | 5.30k | context = transport_get_context(transport); |
582 | 5.30k | WINPR_ASSERT(context); |
583 | 5.30k | WINPR_ASSERT(context->settings); |
584 | | |
585 | 5.30k | if (totalSize > |
586 | 5.30k | freerdp_settings_get_uint32(context->settings, FreeRDP_MultifragMaxRequestSize)) |
587 | 120 | { |
588 | 120 | WLog_ERR( |
589 | 120 | TAG, "Total size (%" PRIuz ") exceeds MultifragMaxRequestSize (%" PRIu32 ")", |
590 | 120 | totalSize, |
591 | 120 | freerdp_settings_get_uint32(context->settings, FreeRDP_MultifragMaxRequestSize)); |
592 | 120 | goto out_fail; |
593 | 120 | } |
594 | | |
595 | 5.18k | if (fragmentation == FASTPATH_FRAGMENT_FIRST) |
596 | 1.55k | { |
597 | 1.55k | if (fastpath->fragmentation != -1) |
598 | 31 | { |
599 | 31 | WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_FIRST"); |
600 | 31 | goto out_fail; |
601 | 31 | } |
602 | | |
603 | 1.52k | fastpath->fragmentation = FASTPATH_FRAGMENT_FIRST; |
604 | 1.52k | } |
605 | 3.63k | else if (fragmentation == FASTPATH_FRAGMENT_NEXT) |
606 | 2.00k | { |
607 | 2.00k | if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && |
608 | 1.52k | (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) |
609 | 326 | { |
610 | 326 | WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_NEXT"); |
611 | 326 | goto out_fail; |
612 | 326 | } |
613 | | |
614 | 1.67k | fastpath->fragmentation = FASTPATH_FRAGMENT_NEXT; |
615 | 1.67k | } |
616 | 1.62k | else if (fragmentation == FASTPATH_FRAGMENT_LAST) |
617 | 1.62k | { |
618 | 1.62k | if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && |
619 | 705 | (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) |
620 | 308 | { |
621 | 308 | WLog_ERR(TAG, "Unexpected FASTPATH_FRAGMENT_LAST"); |
622 | 308 | goto out_fail; |
623 | 308 | } |
624 | | |
625 | 1.32k | fastpath->fragmentation = -1; |
626 | 1.32k | status = fastpath_recv_update(fastpath, updateCode, fastpath->updateData); |
627 | | |
628 | 1.32k | if (status < 0) |
629 | 13 | { |
630 | 13 | WLog_ERR(TAG, "fastpath_recv_update() - %i", status); |
631 | 13 | goto out_fail; |
632 | 13 | } |
633 | 1.32k | } |
634 | 5.18k | } |
635 | | |
636 | 24.2k | return status; |
637 | 9.58k | out_fail: |
638 | 9.58k | return -1; |
639 | 33.8k | } |
640 | | |
641 | | state_run_t fastpath_recv_updates(rdpFastPath* fastpath, wStream* s) |
642 | 17.7k | { |
643 | 17.7k | state_run_t rc = STATE_RUN_FAILED; |
644 | | |
645 | 17.7k | WINPR_ASSERT(s); |
646 | 17.7k | WINPR_ASSERT(fastpath); |
647 | 17.7k | WINPR_ASSERT(fastpath->rdp); |
648 | | |
649 | 41.9k | while (Stream_GetRemainingLength(s) >= 3) |
650 | 41.0k | { |
651 | 41.0k | if (fastpath_recv_update_data(fastpath, s) < 0) |
652 | 16.8k | { |
653 | 16.8k | WLog_ERR(TAG, "fastpath_recv_update_data() fail"); |
654 | 16.8k | rc = STATE_RUN_FAILED; |
655 | 16.8k | goto fail; |
656 | 16.8k | } |
657 | 41.0k | } |
658 | | |
659 | 903 | rc = STATE_RUN_SUCCESS; |
660 | 17.7k | fail: |
661 | | |
662 | 17.7k | return rc; |
663 | 903 | } |
664 | | |
665 | | static BOOL fastpath_read_input_event_header(wStream* s, BYTE* eventFlags, BYTE* eventCode) |
666 | 105k | { |
667 | 105k | BYTE eventHeader = 0; |
668 | | |
669 | 105k | WINPR_ASSERT(s); |
670 | 105k | WINPR_ASSERT(eventFlags); |
671 | 105k | WINPR_ASSERT(eventCode); |
672 | | |
673 | 105k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
674 | 877 | return FALSE; |
675 | | |
676 | 105k | Stream_Read_UINT8(s, eventHeader); /* eventHeader (1 byte) */ |
677 | 105k | *eventFlags = (eventHeader & 0x1F); |
678 | 105k | *eventCode = (eventHeader >> 5); |
679 | 105k | return TRUE; |
680 | 105k | } |
681 | | |
682 | | static BOOL fastpath_recv_input_event_scancode(rdpFastPath* fastpath, wStream* s, BYTE eventFlags) |
683 | 60.6k | { |
684 | 60.6k | WINPR_ASSERT(fastpath); |
685 | 60.6k | WINPR_ASSERT(fastpath->rdp); |
686 | 60.6k | WINPR_ASSERT(fastpath->rdp->input); |
687 | 60.6k | WINPR_ASSERT(s); |
688 | | |
689 | 60.6k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
690 | 175 | return FALSE; |
691 | | |
692 | 60.4k | rdpInput* input = fastpath->rdp->input; |
693 | | |
694 | 60.4k | const UINT8 code = Stream_Get_UINT8(s); /* keyCode (1 byte) */ |
695 | | |
696 | 60.4k | UINT16 flags = 0; |
697 | 60.4k | if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE)) |
698 | 9.02k | flags |= KBD_FLAGS_RELEASE; |
699 | | |
700 | 60.4k | if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_EXTENDED)) |
701 | 32.5k | flags |= KBD_FLAGS_EXTENDED; |
702 | | |
703 | 60.4k | if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_PREFIX_E1)) |
704 | 8.10k | flags |= KBD_FLAGS_EXTENDED1; |
705 | | |
706 | 60.4k | return IFCALLRESULT(TRUE, input->KeyboardEvent, input, flags, code); |
707 | 60.6k | } |
708 | | |
709 | | static BOOL fastpath_recv_input_event_mouse(rdpFastPath* fastpath, wStream* s, |
710 | | WINPR_ATTR_UNUSED BYTE eventFlags) |
711 | 6.26k | { |
712 | 6.26k | rdpInput* input = nullptr; |
713 | 6.26k | UINT16 pointerFlags = 0; |
714 | 6.26k | UINT16 xPos = 0; |
715 | 6.26k | UINT16 yPos = 0; |
716 | 6.26k | WINPR_ASSERT(fastpath); |
717 | 6.26k | WINPR_ASSERT(fastpath->rdp); |
718 | 6.26k | WINPR_ASSERT(fastpath->rdp->input); |
719 | 6.26k | WINPR_ASSERT(s); |
720 | | |
721 | 6.26k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 6)) |
722 | 153 | return FALSE; |
723 | | |
724 | 6.10k | input = fastpath->rdp->input; |
725 | | |
726 | 6.10k | Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ |
727 | 6.10k | Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ |
728 | 6.10k | Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ |
729 | 6.10k | return IFCALLRESULT(TRUE, input->MouseEvent, input, pointerFlags, xPos, yPos); |
730 | 6.26k | } |
731 | | |
732 | | static BOOL fastpath_recv_input_event_relmouse(rdpFastPath* fastpath, wStream* s, |
733 | | WINPR_ATTR_UNUSED BYTE eventFlags) |
734 | 5.29k | { |
735 | 5.29k | rdpInput* input = nullptr; |
736 | 5.29k | UINT16 pointerFlags = 0; |
737 | 5.29k | INT16 xDelta = 0; |
738 | 5.29k | INT16 yDelta = 0; |
739 | 5.29k | WINPR_ASSERT(fastpath); |
740 | 5.29k | WINPR_ASSERT(fastpath->rdp); |
741 | 5.29k | WINPR_ASSERT(fastpath->rdp->context); |
742 | 5.29k | WINPR_ASSERT(fastpath->rdp->input); |
743 | 5.29k | WINPR_ASSERT(s); |
744 | | |
745 | 5.29k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 6)) |
746 | 60 | return FALSE; |
747 | | |
748 | 5.23k | input = fastpath->rdp->input; |
749 | | |
750 | 5.23k | Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ |
751 | 5.23k | Stream_Read_INT16(s, xDelta); /* xDelta (2 bytes) */ |
752 | 5.23k | Stream_Read_INT16(s, yDelta); /* yDelta (2 bytes) */ |
753 | | |
754 | 5.23k | if (!freerdp_settings_get_bool(input->context->settings, FreeRDP_HasRelativeMouseEvent)) |
755 | 0 | { |
756 | 0 | WLog_ERR(TAG, |
757 | 0 | "Received relative mouse event(flags=0x%04" PRIx16 ", xPos=%" PRId16 |
758 | 0 | ", yPos=%" PRId16 "), but we did not announce support for that", |
759 | 0 | pointerFlags, xDelta, yDelta); |
760 | 0 | return FALSE; |
761 | 0 | } |
762 | | |
763 | 5.23k | return IFCALLRESULT(TRUE, input->RelMouseEvent, input, pointerFlags, xDelta, yDelta); |
764 | 5.23k | } |
765 | | |
766 | | static BOOL fastpath_recv_input_event_qoe(rdpFastPath* fastpath, wStream* s, |
767 | | WINPR_ATTR_UNUSED BYTE eventFlags) |
768 | 2.83k | { |
769 | 2.83k | WINPR_ASSERT(fastpath); |
770 | 2.83k | WINPR_ASSERT(fastpath->rdp); |
771 | 2.83k | WINPR_ASSERT(fastpath->rdp->context); |
772 | 2.83k | WINPR_ASSERT(fastpath->rdp->input); |
773 | 2.83k | WINPR_ASSERT(s); |
774 | | |
775 | 2.83k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) |
776 | 61 | return FALSE; |
777 | | |
778 | 2.77k | rdpInput* input = fastpath->rdp->input; |
779 | | |
780 | 2.77k | UINT32 timestampMS = 0; |
781 | 2.77k | Stream_Read_UINT32(s, timestampMS); /* timestamp (4 bytes) */ |
782 | | |
783 | 2.77k | if (!freerdp_settings_get_bool(input->context->settings, FreeRDP_HasQoeEvent)) |
784 | 0 | { |
785 | 0 | WLog_ERR(TAG, |
786 | 0 | "Received qoe event(timestamp=%" PRIu32 |
787 | 0 | "ms), but we did not announce support for that", |
788 | 0 | timestampMS); |
789 | 0 | return FALSE; |
790 | 0 | } |
791 | | |
792 | 2.77k | return IFCALLRESULT(TRUE, input->QoEEvent, input, timestampMS); |
793 | 2.77k | } |
794 | | |
795 | | static BOOL fastpath_recv_input_event_mousex(rdpFastPath* fastpath, wStream* s, |
796 | | WINPR_ATTR_UNUSED BYTE eventFlags) |
797 | 4.15k | { |
798 | 4.15k | rdpInput* input = nullptr; |
799 | 4.15k | UINT16 pointerFlags = 0; |
800 | 4.15k | UINT16 xPos = 0; |
801 | 4.15k | UINT16 yPos = 0; |
802 | | |
803 | 4.15k | WINPR_ASSERT(fastpath); |
804 | 4.15k | WINPR_ASSERT(fastpath->rdp); |
805 | 4.15k | WINPR_ASSERT(fastpath->rdp->context); |
806 | 4.15k | WINPR_ASSERT(fastpath->rdp->input); |
807 | 4.15k | WINPR_ASSERT(s); |
808 | | |
809 | 4.15k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 6)) |
810 | 70 | return FALSE; |
811 | | |
812 | 4.08k | input = fastpath->rdp->input; |
813 | | |
814 | 4.08k | Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ |
815 | 4.08k | Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ |
816 | 4.08k | Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ |
817 | | |
818 | 4.08k | if (!freerdp_settings_get_bool(input->context->settings, FreeRDP_HasExtendedMouseEvent)) |
819 | 0 | { |
820 | 0 | WLog_ERR(TAG, |
821 | 0 | "Received extended mouse event(flags=0x%04" PRIx16 ", xPos=%" PRIu16 |
822 | 0 | ", yPos=%" PRIu16 "), but we did not announce support for that", |
823 | 0 | pointerFlags, xPos, yPos); |
824 | 0 | return FALSE; |
825 | 0 | } |
826 | | |
827 | 4.08k | return IFCALLRESULT(TRUE, input->ExtendedMouseEvent, input, pointerFlags, xPos, yPos); |
828 | 4.08k | } |
829 | | |
830 | | static BOOL fastpath_recv_input_event_sync(rdpFastPath* fastpath, WINPR_ATTR_UNUSED wStream* s, |
831 | | BYTE eventFlags) |
832 | 7.99k | { |
833 | 7.99k | rdpInput* input = nullptr; |
834 | | |
835 | 7.99k | WINPR_ASSERT(fastpath); |
836 | 7.99k | WINPR_ASSERT(fastpath->rdp); |
837 | 7.99k | WINPR_ASSERT(fastpath->rdp->input); |
838 | 7.99k | WINPR_ASSERT(s); |
839 | | |
840 | 7.99k | input = fastpath->rdp->input; |
841 | 7.99k | return IFCALLRESULT(TRUE, input->SynchronizeEvent, input, eventFlags); |
842 | 7.99k | } |
843 | | |
844 | | static BOOL fastpath_recv_input_event_unicode(rdpFastPath* fastpath, wStream* s, BYTE eventFlags) |
845 | 1.90k | { |
846 | 1.90k | UINT16 unicodeCode = 0; |
847 | 1.90k | UINT16 flags = 0; |
848 | | |
849 | 1.90k | WINPR_ASSERT(fastpath); |
850 | 1.90k | WINPR_ASSERT(s); |
851 | | |
852 | 1.90k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) |
853 | 37 | return FALSE; |
854 | | |
855 | 1.86k | Stream_Read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ |
856 | 1.86k | flags = 0; |
857 | | |
858 | 1.86k | if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE)) |
859 | 1.26k | flags |= KBD_FLAGS_RELEASE; |
860 | | |
861 | 1.86k | WINPR_ASSERT(fastpath->rdp); |
862 | 1.86k | WINPR_ASSERT(fastpath->rdp); |
863 | 1.86k | WINPR_ASSERT(fastpath->rdp->input); |
864 | 1.86k | return IFCALLRESULT(FALSE, fastpath->rdp->input->UnicodeKeyboardEvent, fastpath->rdp->input, |
865 | 1.90k | flags, unicodeCode); |
866 | 1.90k | } |
867 | | |
868 | | static BOOL fastpath_recv_input_event(rdpFastPath* fastpath, wStream* s) |
869 | 105k | { |
870 | 105k | BYTE eventFlags = 0; |
871 | 105k | BYTE eventCode = 0; |
872 | | |
873 | 105k | WINPR_ASSERT(fastpath); |
874 | 105k | WINPR_ASSERT(s); |
875 | | |
876 | 105k | if (!fastpath_read_input_event_header(s, &eventFlags, &eventCode)) |
877 | 877 | return FALSE; |
878 | | |
879 | 105k | switch (eventCode) |
880 | 105k | { |
881 | 60.6k | case FASTPATH_INPUT_EVENT_SCANCODE: |
882 | 60.6k | if (!fastpath_recv_input_event_scancode(fastpath, s, eventFlags)) |
883 | 175 | return FALSE; |
884 | | |
885 | 60.4k | break; |
886 | | |
887 | 60.4k | case FASTPATH_INPUT_EVENT_MOUSE: |
888 | 6.26k | if (!fastpath_recv_input_event_mouse(fastpath, s, eventFlags)) |
889 | 153 | return FALSE; |
890 | | |
891 | 6.10k | break; |
892 | | |
893 | 6.10k | case FASTPATH_INPUT_EVENT_MOUSEX: |
894 | 4.15k | if (!fastpath_recv_input_event_mousex(fastpath, s, eventFlags)) |
895 | 70 | return FALSE; |
896 | | |
897 | 4.08k | break; |
898 | | |
899 | 7.99k | case FASTPATH_INPUT_EVENT_SYNC: |
900 | 7.99k | if (!fastpath_recv_input_event_sync(fastpath, s, eventFlags)) |
901 | 0 | return FALSE; |
902 | | |
903 | 7.99k | break; |
904 | | |
905 | 7.99k | case FASTPATH_INPUT_EVENT_UNICODE: |
906 | 1.90k | if (!fastpath_recv_input_event_unicode(fastpath, s, eventFlags)) |
907 | 1.90k | return FALSE; |
908 | | |
909 | 0 | break; |
910 | | |
911 | 5.29k | case TS_FP_RELPOINTER_EVENT: |
912 | 5.29k | if (!fastpath_recv_input_event_relmouse(fastpath, s, eventFlags)) |
913 | 60 | return FALSE; |
914 | | |
915 | 5.23k | break; |
916 | | |
917 | 5.23k | case TS_FP_QOETIMESTAMP_EVENT: |
918 | 2.83k | if (!fastpath_recv_input_event_qoe(fastpath, s, eventFlags)) |
919 | 61 | return FALSE; |
920 | 2.77k | break; |
921 | | |
922 | 15.9k | default: |
923 | 15.9k | WLog_ERR(TAG, "Unknown eventCode %" PRIu8 "", eventCode); |
924 | 15.9k | break; |
925 | 105k | } |
926 | | |
927 | 102k | return TRUE; |
928 | 105k | } |
929 | | |
930 | | state_run_t fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s) |
931 | 17.7k | { |
932 | 17.7k | WINPR_ASSERT(fastpath); |
933 | 17.7k | WINPR_ASSERT(s); |
934 | | |
935 | 17.7k | if (fastpath->numberEvents == 0) |
936 | 17.7k | { |
937 | | /** |
938 | | * If numberEvents is not provided in fpInputHeader, it will be provided |
939 | | * as one additional byte here. |
940 | | */ |
941 | 17.7k | if (!Stream_CheckAndLogRequiredLength(TAG, s, 1)) |
942 | 4.36k | return STATE_RUN_FAILED; |
943 | | |
944 | 13.3k | Stream_Read_UINT8(s, fastpath->numberEvents); /* eventHeader (1 byte) */ |
945 | 13.3k | } |
946 | | |
947 | 115k | for (BYTE i = 0; i < fastpath->numberEvents; i++) |
948 | 105k | { |
949 | 105k | if (!fastpath_recv_input_event(fastpath, s)) |
950 | 3.29k | return STATE_RUN_FAILED; |
951 | 105k | } |
952 | | |
953 | 10.0k | return STATE_RUN_SUCCESS; |
954 | 13.3k | } |
955 | | |
956 | | static UINT32 fastpath_get_sec_bytes(rdpRdp* rdp) |
957 | 0 | { |
958 | 0 | UINT32 sec_bytes = 0; |
959 | 0 | sec_bytes = 0; |
960 | |
|
961 | 0 | if (!rdp) |
962 | 0 | return 0; |
963 | | |
964 | 0 | if (rdp->do_crypt) |
965 | 0 | { |
966 | 0 | sec_bytes = 8; |
967 | |
|
968 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
969 | 0 | ENCRYPTION_METHOD_FIPS) |
970 | 0 | sec_bytes += 4; |
971 | 0 | } |
972 | |
|
973 | 0 | return sec_bytes; |
974 | 0 | } |
975 | | |
976 | | wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath, UINT16* sec_flags) |
977 | 0 | { |
978 | 0 | if (!fastpath || !fastpath->rdp) |
979 | 0 | return nullptr; |
980 | | |
981 | 0 | rdpRdp* rdp = fastpath->rdp; |
982 | 0 | wStream* s = transport_send_stream_init(rdp->transport, 256); |
983 | |
|
984 | 0 | if (!s) |
985 | 0 | return nullptr; |
986 | | |
987 | 0 | Stream_Seek(s, 3); /* fpInputHeader, length1 and length2 */ |
988 | |
|
989 | 0 | if (rdp->do_crypt) |
990 | 0 | { |
991 | 0 | *sec_flags |= SEC_ENCRYPT; |
992 | |
|
993 | 0 | if (rdp->do_secure_checksum) |
994 | 0 | *sec_flags |= SEC_SECURE_CHECKSUM; |
995 | 0 | } |
996 | |
|
997 | 0 | Stream_Seek(s, fastpath_get_sec_bytes(rdp)); |
998 | 0 | return s; |
999 | 0 | } |
1000 | | |
1001 | | wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode, |
1002 | | UINT16* sec_flags) |
1003 | 0 | { |
1004 | 0 | wStream* s = nullptr; |
1005 | 0 | s = fastpath_input_pdu_init_header(fastpath, sec_flags); |
1006 | |
|
1007 | 0 | if (!s) |
1008 | 0 | return nullptr; |
1009 | | |
1010 | 0 | WINPR_ASSERT(eventCode < 8); |
1011 | 0 | WINPR_ASSERT(eventFlags < 0x20); |
1012 | 0 | Stream_Write_UINT8(s, (UINT8)(eventFlags | (eventCode << 5))); /* eventHeader (1 byte) */ |
1013 | 0 | return s; |
1014 | 0 | } |
1015 | | |
1016 | | BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, size_t iNumEvents, |
1017 | | UINT16 sec_flags) |
1018 | 0 | { |
1019 | 0 | BOOL rc = FALSE; |
1020 | 0 | BYTE eventHeader = 0; |
1021 | 0 | BOOL should_unlock = FALSE; |
1022 | 0 | rdpRdp* rdp = nullptr; |
1023 | |
|
1024 | 0 | WINPR_ASSERT(iNumEvents > 0); |
1025 | 0 | if (!s) |
1026 | 0 | return FALSE; |
1027 | | |
1028 | 0 | if (!fastpath) |
1029 | 0 | goto fail; |
1030 | | |
1031 | 0 | rdp = fastpath->rdp; |
1032 | 0 | WINPR_ASSERT(rdp); |
1033 | |
|
1034 | 0 | { |
1035 | 0 | const CONNECTION_STATE state = rdp_get_state(rdp); |
1036 | 0 | if (!rdp_is_active_state(rdp)) |
1037 | 0 | { |
1038 | 0 | WLog_WARN(TAG, "called before activation [%s]", rdp_state_string(state)); |
1039 | 0 | goto fail; |
1040 | 0 | } |
1041 | 0 | } |
1042 | | |
1043 | | /* |
1044 | | * A maximum of 15 events are allowed per request |
1045 | | * if the optional numEvents field isn't used |
1046 | | * see MS-RDPBCGR 2.2.8.1.2 for details |
1047 | | */ |
1048 | 0 | if (iNumEvents > 15) |
1049 | 0 | goto fail; |
1050 | | |
1051 | 0 | { |
1052 | 0 | size_t length = Stream_GetPosition(s); |
1053 | |
|
1054 | 0 | if (length >= (2u << 14)) |
1055 | 0 | { |
1056 | 0 | WLog_ERR(TAG, "Maximum FastPath PDU length is 32767"); |
1057 | 0 | goto fail; |
1058 | 0 | } |
1059 | | |
1060 | 0 | eventHeader = FASTPATH_INPUT_ACTION_FASTPATH; |
1061 | 0 | eventHeader |= (iNumEvents << 2); /* numberEvents */ |
1062 | |
|
1063 | 0 | if (sec_flags & SEC_ENCRYPT) |
1064 | 0 | eventHeader |= (FASTPATH_INPUT_ENCRYPTED << 6); |
1065 | |
|
1066 | 0 | if (sec_flags & SEC_SECURE_CHECKSUM) |
1067 | 0 | eventHeader |= (FASTPATH_INPUT_SECURE_CHECKSUM << 6); |
1068 | |
|
1069 | 0 | Stream_ResetPosition(s); |
1070 | 0 | Stream_Write_UINT8(s, eventHeader); |
1071 | | /* Write length later, RDP encryption might add a padding */ |
1072 | 0 | Stream_Seek(s, 2); |
1073 | |
|
1074 | 0 | if (sec_flags & SEC_ENCRYPT) |
1075 | 0 | { |
1076 | 0 | security_lock(rdp); |
1077 | 0 | should_unlock = TRUE; |
1078 | |
|
1079 | 0 | const size_t sec_bytes = fastpath_get_sec_bytes(fastpath->rdp); |
1080 | 0 | if (sec_bytes + 3ULL > length) |
1081 | 0 | goto fail; |
1082 | | |
1083 | 0 | BYTE* fpInputEvents = Stream_PointerAs(s, BYTE) + sec_bytes; |
1084 | 0 | const UINT16 fpInputEvents_length = (UINT16)(length - 3 - sec_bytes); |
1085 | |
|
1086 | 0 | WINPR_ASSERT(rdp->settings); |
1087 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
1088 | 0 | ENCRYPTION_METHOD_FIPS) |
1089 | 0 | { |
1090 | 0 | BYTE pad = 0; |
1091 | |
|
1092 | 0 | if ((pad = 8 - (fpInputEvents_length % 8)) == 8) |
1093 | 0 | pad = 0; |
1094 | |
|
1095 | 0 | Stream_Write_UINT16(s, 0x10); /* length */ |
1096 | 0 | Stream_Write_UINT8(s, 0x1); /* TSFIPS_VERSION 1*/ |
1097 | 0 | Stream_Write_UINT8(s, pad); /* padding */ |
1098 | |
|
1099 | 0 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 8)) |
1100 | 0 | goto fail; |
1101 | | |
1102 | 0 | if (!security_hmac_signature(fpInputEvents, fpInputEvents_length, Stream_Pointer(s), |
1103 | 0 | 8, rdp)) |
1104 | 0 | goto fail; |
1105 | | |
1106 | 0 | if (pad) |
1107 | 0 | memset(fpInputEvents + fpInputEvents_length, 0, pad); |
1108 | |
|
1109 | 0 | if (!security_fips_encrypt(fpInputEvents, fpInputEvents_length + pad, rdp)) |
1110 | 0 | goto fail; |
1111 | | |
1112 | 0 | length += pad; |
1113 | 0 | } |
1114 | 0 | else |
1115 | 0 | { |
1116 | 0 | BOOL res = 0; |
1117 | 0 | if (!Stream_CheckAndLogRequiredCapacity(TAG, s, 8)) |
1118 | 0 | goto fail; |
1119 | 0 | if (sec_flags & SEC_SECURE_CHECKSUM) |
1120 | 0 | res = security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, |
1121 | 0 | TRUE, Stream_Pointer(s), 8); |
1122 | 0 | else |
1123 | 0 | res = security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, |
1124 | 0 | Stream_Pointer(s), 8); |
1125 | |
|
1126 | 0 | if (!res || !security_encrypt(fpInputEvents, fpInputEvents_length, rdp)) |
1127 | 0 | goto fail; |
1128 | 0 | } |
1129 | 0 | } |
1130 | | |
1131 | | /* |
1132 | | * We always encode length in two bytes, even though we could use |
1133 | | * only one byte if length <= 0x7F. It is just easier that way, |
1134 | | * because we can leave room for fixed-length header, store all |
1135 | | * the data first and then store the header. |
1136 | | */ |
1137 | 0 | WINPR_ASSERT(length < UINT16_MAX); |
1138 | 0 | if (!Stream_SetPosition(s, 1)) |
1139 | 0 | goto fail; |
1140 | 0 | Stream_Write_UINT16_BE(s, 0x8000 | (UINT16)length); |
1141 | 0 | if (!Stream_SetPosition(s, length)) |
1142 | 0 | goto fail; |
1143 | 0 | Stream_SealLength(s); |
1144 | 0 | } |
1145 | | |
1146 | 0 | if (transport_write(rdp->transport, s) < 0) |
1147 | 0 | goto fail; |
1148 | | |
1149 | 0 | rc = TRUE; |
1150 | 0 | fail: |
1151 | 0 | if (should_unlock) |
1152 | 0 | security_unlock(rdp); |
1153 | 0 | Stream_Release(s); |
1154 | 0 | return rc; |
1155 | 0 | } |
1156 | | |
1157 | | BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s, UINT16 sec_flags) |
1158 | 0 | { |
1159 | 0 | return fastpath_send_multiple_input_pdu(fastpath, s, 1, sec_flags); |
1160 | 0 | } |
1161 | | |
1162 | | wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) |
1163 | 3.27k | { |
1164 | 3.27k | return transport_send_stream_init(fastpath->rdp->transport, FASTPATH_MAX_PACKET_SIZE); |
1165 | 3.27k | } |
1166 | | |
1167 | | wStream* fastpath_update_pdu_init_new(WINPR_ATTR_UNUSED rdpFastPath* fastpath) |
1168 | 15.9k | { |
1169 | 15.9k | wStream* s = nullptr; |
1170 | 15.9k | s = Stream_New(nullptr, FASTPATH_MAX_PACKET_SIZE); |
1171 | 15.9k | return s; |
1172 | 15.9k | } |
1173 | | |
1174 | | BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s, |
1175 | | BOOL skipCompression) |
1176 | 3.94k | { |
1177 | 3.94k | BOOL status = TRUE; |
1178 | 3.94k | wStream* fs = nullptr; |
1179 | 3.94k | rdpSettings* settings = nullptr; |
1180 | 3.94k | rdpRdp* rdp = nullptr; |
1181 | 3.94k | UINT32 fpHeaderSize = 6; |
1182 | 3.94k | UINT32 fpUpdatePduHeaderSize = 0; |
1183 | 3.94k | UINT32 fpUpdateHeaderSize = 0; |
1184 | 3.94k | FASTPATH_UPDATE_PDU_HEADER fpUpdatePduHeader = WINPR_C_ARRAY_INIT; |
1185 | 3.94k | FASTPATH_UPDATE_HEADER fpUpdateHeader = WINPR_C_ARRAY_INIT; |
1186 | 3.94k | UINT16 sec_flags = 0; |
1187 | | |
1188 | 3.94k | if (!fastpath || !fastpath->rdp || !fastpath->fs || !s) |
1189 | 0 | return FALSE; |
1190 | | |
1191 | 3.94k | rdp = fastpath->rdp; |
1192 | 3.94k | fs = fastpath->fs; |
1193 | 3.94k | settings = rdp->settings; |
1194 | | |
1195 | 3.94k | if (!settings) |
1196 | 0 | return FALSE; |
1197 | | |
1198 | 3.94k | UINT16 maxLength = FASTPATH_MAX_PACKET_SIZE - 20; |
1199 | | |
1200 | 3.94k | if (freerdp_settings_get_bool(rdp->settings, FreeRDP_CompressionEnabled) && !skipCompression) |
1201 | 3.94k | { |
1202 | 3.94k | const UINT16 CompressionMaxSize = bulk_compression_max_size(rdp->bulk); |
1203 | 3.94k | maxLength = (maxLength < CompressionMaxSize) ? maxLength : CompressionMaxSize; |
1204 | 3.94k | maxLength -= 20; |
1205 | 3.94k | } |
1206 | | |
1207 | 3.94k | size_t totalLength = Stream_GetPosition(s); |
1208 | 3.94k | Stream_ResetPosition(s); |
1209 | | |
1210 | | /* check if fast path output is possible */ |
1211 | 3.94k | if (!freerdp_settings_get_bool(rdp->settings, FreeRDP_FastPathOutput)) |
1212 | 0 | { |
1213 | 0 | WLog_ERR(TAG, "client does not support fast path output"); |
1214 | 0 | return FALSE; |
1215 | 0 | } |
1216 | | |
1217 | | /* check if the client's fast path pdu buffer is large enough */ |
1218 | 3.94k | if (totalLength > freerdp_settings_get_uint32(settings, FreeRDP_MultifragMaxRequestSize)) |
1219 | 3.82k | { |
1220 | 3.82k | WLog_ERR(TAG, |
1221 | 3.82k | "fast path update size (%" PRIuz |
1222 | 3.82k | ") exceeds the client's maximum request size (%" PRIu32 ")", |
1223 | 3.82k | totalLength, |
1224 | 3.82k | freerdp_settings_get_uint32(settings, FreeRDP_MultifragMaxRequestSize)); |
1225 | 3.82k | return FALSE; |
1226 | 3.82k | } |
1227 | | |
1228 | 127 | if (rdp->do_crypt) |
1229 | 0 | { |
1230 | 0 | sec_flags |= SEC_ENCRYPT; |
1231 | |
|
1232 | 0 | if (rdp->do_secure_checksum) |
1233 | 0 | sec_flags |= SEC_SECURE_CHECKSUM; |
1234 | 0 | } |
1235 | | |
1236 | 127 | for (int fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) |
1237 | 127 | { |
1238 | 127 | UINT32 DstSize = 0; |
1239 | 127 | const BYTE* pDstData = nullptr; |
1240 | 127 | UINT32 compressionFlags = 0; |
1241 | 127 | BYTE pad = 0; |
1242 | 127 | BYTE* pSignature = nullptr; |
1243 | 127 | fpUpdatePduHeader.action = 0; |
1244 | 127 | fpUpdatePduHeader.secFlags = 0; |
1245 | 127 | fpUpdateHeader.compression = 0; |
1246 | 127 | fpUpdateHeader.compressionFlags = 0; |
1247 | 127 | fpUpdateHeader.updateCode = updateCode; |
1248 | 127 | fpUpdateHeader.size = (UINT16)(totalLength > maxLength) ? maxLength : (UINT16)totalLength; |
1249 | 127 | const BYTE* pSrcData = Stream_Pointer(s); |
1250 | 127 | UINT32 SrcSize = DstSize = fpUpdateHeader.size; |
1251 | 127 | BOOL should_unlock = FALSE; |
1252 | | |
1253 | 127 | if (sec_flags & SEC_ENCRYPT) |
1254 | 0 | fpUpdatePduHeader.secFlags |= FASTPATH_OUTPUT_ENCRYPTED; |
1255 | | |
1256 | 127 | if (sec_flags & SEC_SECURE_CHECKSUM) |
1257 | 0 | fpUpdatePduHeader.secFlags |= FASTPATH_OUTPUT_SECURE_CHECKSUM; |
1258 | | |
1259 | 127 | if (freerdp_settings_get_bool(settings, FreeRDP_CompressionEnabled) && !skipCompression) |
1260 | 127 | { |
1261 | 127 | if (bulk_compress(rdp->bulk, pSrcData, SrcSize, &pDstData, &DstSize, |
1262 | 127 | &compressionFlags) >= 0) |
1263 | 127 | { |
1264 | 127 | if (compressionFlags) |
1265 | 0 | { |
1266 | 0 | WINPR_ASSERT(compressionFlags <= UINT8_MAX); |
1267 | 0 | fpUpdateHeader.compressionFlags = (UINT8)compressionFlags; |
1268 | 0 | fpUpdateHeader.compression = FASTPATH_OUTPUT_COMPRESSION_USED; |
1269 | 0 | } |
1270 | 127 | } |
1271 | 127 | } |
1272 | | |
1273 | 127 | if (!fpUpdateHeader.compression) |
1274 | 127 | { |
1275 | 127 | pDstData = Stream_Pointer(s); |
1276 | 127 | DstSize = fpUpdateHeader.size; |
1277 | 127 | } |
1278 | | |
1279 | 127 | if (DstSize > UINT16_MAX) |
1280 | 0 | return FALSE; |
1281 | 127 | fpUpdateHeader.size = (UINT16)DstSize; |
1282 | 127 | totalLength -= SrcSize; |
1283 | | |
1284 | 127 | if (totalLength == 0) |
1285 | 127 | fpUpdateHeader.fragmentation = |
1286 | 127 | (fragment == 0) ? FASTPATH_FRAGMENT_SINGLE : FASTPATH_FRAGMENT_LAST; |
1287 | 0 | else |
1288 | 0 | fpUpdateHeader.fragmentation = |
1289 | 0 | (fragment == 0) ? FASTPATH_FRAGMENT_FIRST : FASTPATH_FRAGMENT_NEXT; |
1290 | | |
1291 | 127 | fpUpdateHeaderSize = fastpath_get_update_header_size(&fpUpdateHeader); |
1292 | 127 | fpUpdatePduHeaderSize = fastpath_get_update_pdu_header_size(&fpUpdatePduHeader, rdp); |
1293 | 127 | fpHeaderSize = fpUpdateHeaderSize + fpUpdatePduHeaderSize; |
1294 | | |
1295 | 127 | if (sec_flags & SEC_ENCRYPT) |
1296 | 0 | { |
1297 | 0 | pSignature = Stream_Buffer(fs) + 3; |
1298 | |
|
1299 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
1300 | 0 | ENCRYPTION_METHOD_FIPS) |
1301 | 0 | { |
1302 | 0 | pSignature += 4; |
1303 | |
|
1304 | 0 | if ((pad = 8 - ((DstSize + fpUpdateHeaderSize) % 8)) == 8) |
1305 | 0 | pad = 0; |
1306 | |
|
1307 | 0 | fpUpdatePduHeader.fipsInformation[0] = 0x10; |
1308 | 0 | fpUpdatePduHeader.fipsInformation[1] = 0x00; |
1309 | 0 | fpUpdatePduHeader.fipsInformation[2] = 0x01; |
1310 | 0 | fpUpdatePduHeader.fipsInformation[3] = pad; |
1311 | 0 | } |
1312 | 0 | } |
1313 | | |
1314 | 127 | const size_t len = fpUpdateHeader.size + fpHeaderSize + pad; |
1315 | 127 | if (len > UINT16_MAX) |
1316 | 0 | return FALSE; |
1317 | | |
1318 | 127 | fpUpdatePduHeader.length = (UINT16)len; |
1319 | 127 | Stream_ResetPosition(fs); |
1320 | 127 | if (!fastpath_write_update_pdu_header(fs, &fpUpdatePduHeader, rdp)) |
1321 | 0 | return FALSE; |
1322 | 127 | if (!fastpath_write_update_header(fs, &fpUpdateHeader)) |
1323 | 0 | return FALSE; |
1324 | | |
1325 | 127 | if (!Stream_CheckAndLogRequiredCapacity(TAG, (fs), (size_t)DstSize + pad)) |
1326 | 0 | return FALSE; |
1327 | 127 | Stream_Write(fs, pDstData, DstSize); |
1328 | | |
1329 | 127 | if (pad) |
1330 | 0 | Stream_Zero(fs, pad); |
1331 | | |
1332 | 127 | BOOL res = FALSE; |
1333 | 127 | if (sec_flags & SEC_ENCRYPT) |
1334 | 0 | { |
1335 | 0 | security_lock(rdp); |
1336 | |
|
1337 | 0 | should_unlock = TRUE; |
1338 | 0 | UINT32 dataSize = fpUpdateHeaderSize + DstSize + pad; |
1339 | 0 | BYTE* data = Stream_PointerAs(fs, BYTE) - dataSize; |
1340 | |
|
1341 | 0 | if (freerdp_settings_get_uint32(rdp->settings, FreeRDP_EncryptionMethods) == |
1342 | 0 | ENCRYPTION_METHOD_FIPS) |
1343 | 0 | { |
1344 | | // TODO: Ensure stream capacity |
1345 | 0 | if (!security_hmac_signature(data, dataSize - pad, pSignature, 8, rdp)) |
1346 | 0 | goto unlock; |
1347 | | |
1348 | 0 | if (!security_fips_encrypt(data, dataSize, rdp)) |
1349 | 0 | goto unlock; |
1350 | 0 | } |
1351 | 0 | else |
1352 | 0 | { |
1353 | | // TODO: Ensure stream capacity |
1354 | 0 | if (sec_flags & SEC_SECURE_CHECKSUM) |
1355 | 0 | status = |
1356 | 0 | security_salted_mac_signature(rdp, data, dataSize, TRUE, pSignature, 8); |
1357 | 0 | else |
1358 | 0 | status = security_mac_signature(rdp, data, dataSize, pSignature, 8); |
1359 | |
|
1360 | 0 | if (!status || !security_encrypt(data, dataSize, rdp)) |
1361 | 0 | goto unlock; |
1362 | 0 | } |
1363 | 0 | } |
1364 | 127 | res = TRUE; |
1365 | | |
1366 | 127 | Stream_SealLength(fs); |
1367 | | |
1368 | 127 | if (transport_write(rdp->transport, fs) < 0) |
1369 | 127 | { |
1370 | 127 | status = FALSE; |
1371 | 127 | } |
1372 | | |
1373 | 127 | unlock: |
1374 | 127 | if (should_unlock) |
1375 | 0 | security_unlock(rdp); |
1376 | | |
1377 | 127 | if (!res || !status) |
1378 | 127 | return FALSE; |
1379 | | |
1380 | 0 | Stream_Seek(s, SrcSize); |
1381 | 0 | } |
1382 | | |
1383 | 0 | return status; |
1384 | 127 | } |
1385 | | |
1386 | | rdpFastPath* fastpath_new(rdpRdp* rdp) |
1387 | 17.7k | { |
1388 | 17.7k | rdpFastPath* fastpath = nullptr; |
1389 | | |
1390 | 17.7k | WINPR_ASSERT(rdp); |
1391 | | |
1392 | 17.7k | fastpath = (rdpFastPath*)calloc(1, sizeof(rdpFastPath)); |
1393 | | |
1394 | 17.7k | if (!fastpath) |
1395 | 0 | return nullptr; |
1396 | | |
1397 | 17.7k | fastpath->rdp = rdp; |
1398 | 17.7k | fastpath->fragmentation = -1; |
1399 | 17.7k | fastpath->fs = Stream_New(nullptr, FASTPATH_MAX_PACKET_SIZE); |
1400 | 17.7k | fastpath->updateData = Stream_New(nullptr, FASTPATH_MAX_PACKET_SIZE); |
1401 | | |
1402 | 17.7k | if (!fastpath->fs || !fastpath->updateData) |
1403 | 0 | goto out_free; |
1404 | | |
1405 | 17.7k | return fastpath; |
1406 | 0 | out_free: |
1407 | 0 | fastpath_free(fastpath); |
1408 | 0 | return nullptr; |
1409 | 17.7k | } |
1410 | | |
1411 | | void fastpath_free(rdpFastPath* fastpath) |
1412 | 17.7k | { |
1413 | 17.7k | if (fastpath) |
1414 | 17.7k | { |
1415 | 17.7k | Stream_Free(fastpath->updateData, TRUE); |
1416 | 17.7k | Stream_Free(fastpath->fs, TRUE); |
1417 | 17.7k | free(fastpath); |
1418 | 17.7k | } |
1419 | 17.7k | } |
1420 | | |
1421 | | BYTE fastpath_get_encryption_flags(rdpFastPath* fastpath) |
1422 | 19.8k | { |
1423 | 19.8k | WINPR_ASSERT(fastpath); |
1424 | 19.8k | return fastpath->encryptionFlags; |
1425 | 19.8k | } |
1426 | | |
1427 | | BOOL fastpath_decrypt(rdpFastPath* fastpath, wStream* s, UINT16* length) |
1428 | 17.7k | { |
1429 | 17.7k | WINPR_ASSERT(fastpath); |
1430 | 17.7k | if (fastpath_get_encryption_flags(fastpath) & FASTPATH_OUTPUT_ENCRYPTED) |
1431 | 2.09k | { |
1432 | 2.09k | const UINT16 flags = |
1433 | 2.09k | (fastpath_get_encryption_flags(fastpath) & FASTPATH_OUTPUT_SECURE_CHECKSUM) |
1434 | 2.09k | ? SEC_SECURE_CHECKSUM |
1435 | 2.09k | : 0; |
1436 | | |
1437 | 2.09k | if (!rdp_decrypt(fastpath->rdp, s, length, flags)) |
1438 | 0 | return FALSE; |
1439 | 2.09k | } |
1440 | | |
1441 | 17.7k | return TRUE; |
1442 | 17.7k | } |