FreeRDP
Loading...
Searching...
No Matches
rdpear_common.c
1
18
19#include <winpr/ndr.h>
20#include <winpr/print.h>
21
22#include <rdpear-common/rdpear_common.h>
23#include <rdpear-common/rdpear_asn1.h>
24
25#include <stddef.h>
26#include <freerdp/channels/log.h>
27
28#define TAG CHANNELS_TAG("rdpear")
29
30static char kerberosPackageName[] = {
31 'K', 0, 'e', 0, 'r', 0, 'b', 0, 'e', 0, 'r', 0, 'o', 0, 's', 0
32};
33static char ntlmPackageName[] = { 'N', 0, 'T', 0, 'L', 0, 'M', 0 };
34
35RdpEarPackageType rdpear_packageType_from_name(const WinPrAsn1_OctetString* package)
36{
37 if (package->len == sizeof(kerberosPackageName) &&
38 memcmp(package->data, kerberosPackageName, package->len) == 0)
39 return RDPEAR_PACKAGE_KERBEROS;
40
41 if (package->len == sizeof(ntlmPackageName) &&
42 memcmp(package->data, ntlmPackageName, package->len) == 0)
43 return RDPEAR_PACKAGE_NTLM;
44
45 return RDPEAR_PACKAGE_UNKNOWN;
46}
47
48wStream* rdpear_encodePayload(RdpEarPackageType packageType, wStream* payload)
49{
50 wStream* ret = nullptr;
51 WinPrAsn1Encoder* enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
52 if (!enc)
53 return nullptr;
54
55 /* TSRemoteGuardInnerPacket ::= SEQUENCE { */
56 if (!WinPrAsn1EncSeqContainer(enc))
57 goto out;
58
59 /* packageName [1] OCTET STRING */
60 WinPrAsn1_OctetString packageOctetString;
61 switch (packageType)
62 {
63 case RDPEAR_PACKAGE_KERBEROS:
64 packageOctetString.data = (BYTE*)kerberosPackageName;
65 packageOctetString.len = sizeof(kerberosPackageName);
66 break;
67 case RDPEAR_PACKAGE_NTLM:
68 packageOctetString.data = (BYTE*)ntlmPackageName;
69 packageOctetString.len = sizeof(ntlmPackageName);
70 break;
71 default:
72 goto out;
73 }
74
75 if (!WinPrAsn1EncContextualOctetString(enc, 1, &packageOctetString))
76 goto out;
77
78 /* buffer [2] OCTET STRING*/
79 WinPrAsn1_OctetString payloadOctetString = { Stream_GetPosition(payload),
80 Stream_Buffer(payload) };
81 if (!WinPrAsn1EncContextualOctetString(enc, 2, &payloadOctetString))
82 goto out;
83
84 /* } */
85 if (!WinPrAsn1EncEndContainer(enc))
86 goto out;
87
88 ret = Stream_New(nullptr, 100);
89 if (!ret)
90 goto out;
91
92 if (!WinPrAsn1EncToStream(enc, ret))
93 {
94 Stream_Free(ret, TRUE);
95 ret = nullptr;
96 goto out;
97 }
98out:
99 WinPrAsn1Encoder_Free(&enc);
100 return ret;
101}
102
103#define RDPEAR_SIMPLE_MESSAGE_TYPE(V) \
104 FREERDP_LOCAL BOOL ndr_decoder_read_##V(WinPrNdrDecoder* context, wStream* s, \
105 const void* hints, V* obj) \
106 { \
107 WINPR_UNUSED(hints); \
108 return winpr_ndr_decoder_read_fromDescr(context, s, &V##_struct, obj); \
109 } \
110 FREERDP_LOCAL BOOL ndr_encoder_write_##V(WinPrNdrEncoder* context, wStream* s, \
111 const void* hints, const V* obj) \
112 { \
113 WINPR_UNUSED(hints); \
114 return winpr_ndr_encoder_write_fromDescr(context, s, &V##_struct, obj); \
115 } \
116 FREERDP_LOCAL void ndr_destroy_##V(const void* hints, V* obj) \
117 { \
118 WINPR_UNUSED(hints); \
119 winpr_ndr_struct_destroy(&V##_struct, obj); \
120 } \
121 FREERDP_LOCAL void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj) \
122 { \
123 winpr_ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj); \
124 } \
125 \
126 static BOOL ndr_descr_read_##V(WinPrNdrDecoder* context, wStream* s, const void* hints, \
127 void* obj) \
128 { \
129 return ndr_decoder_read_##V(context, s, hints, obj); \
130 } \
131 static BOOL ndr_descr_write_##V(WinPrNdrEncoder* context, wStream* s, const void* hints, \
132 const void* obj) \
133 { \
134 return ndr_encoder_write_##V(context, s, hints, obj); \
135 } \
136 static void ndr_descr_destroy_##V(const void* hints, void* obj) \
137 { \
138 WINPR_UNUSED(hints); \
139 winpr_ndr_struct_destroy(&V##_struct, obj); \
140 } \
141 static void ndr_descr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const void* obj) \
142 { \
143 winpr_ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj); \
144 } \
145 \
146 static WinPrNdrMessageDescr ndr_##V##_descr_s = { \
147 WINPR_NDR_ARITY_SIMPLE, sizeof(V), ndr_descr_read_##V, ndr_descr_write_##V, \
148 ndr_descr_destroy_##V, ndr_descr_dump_##V, \
149 }; \
150 \
151 WinPrNdrMessageType ndr_##V##_descr(void) \
152 { \
153 return &ndr_##V##_descr_s; \
154 }
155
156static const WinPrNdrFieldStruct KERB_RPC_OCTET_STRING_fields[] = {
157 { "Length", offsetof(KERB_RPC_OCTET_STRING, length), WINPR_NDR_NOT_POINTER, -1,
158 &winpr_ndr_uint32_descr_s, 0, 0 },
159 { "value", offsetof(KERB_RPC_OCTET_STRING, value), WINPR_NDR_POINTER_NON_NULL, 0,
160 &winpr_ndr_uint8Array_descr_s, 0, 0 }
161};
162static const WinPrNdrStructDescr KERB_RPC_OCTET_STRING_struct = { "KERB_RPC_OCTET_STRING", 2,
163 KERB_RPC_OCTET_STRING_fields, 0 };
164
165RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_OCTET_STRING)
166
167/* ============================= KERB_ASN1_DATA ============================== */
168
169static const WinPrNdrFieldStruct KERB_ASN1_DATA_fields[] = {
170 { "Pdu", offsetof(KERB_ASN1_DATA, Pdu), WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint32_descr_s, 0,
171 0 },
172 { "Count", offsetof(KERB_ASN1_DATA, Asn1BufferHints.count), WINPR_NDR_NOT_POINTER, -1,
173 &winpr_ndr_uint32_descr_s, 0, 0 },
174 { "Asn1Buffer", offsetof(KERB_ASN1_DATA, Asn1Buffer), WINPR_NDR_POINTER_NON_NULL, 1,
175 &winpr_ndr_uint8Array_descr_s, 0, 0 }
176};
177static const WinPrNdrStructDescr KERB_ASN1_DATA_struct = { "KERB_ASN1_DATA",
178 ARRAYSIZE(KERB_ASN1_DATA_fields),
179 KERB_ASN1_DATA_fields, 0 };
180
181RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_ASN1_DATA)
182
183/* ============================ RPC_UNICODE_STRING ========================== */
184
185BOOL ndr_decoder_read_RPC_UNICODE_STRING(WinPrNdrDecoder* context, wStream* s, const void* hints,
187{
188 WINPR_ASSERT(res);
190 "RPC_UNICODE_STRING.Buffer",
191 &res->lenHints,
192 (void*)&res->Buffer,
193 TRUE,
194 winpr_ndr_wcharVaryingArray_descr() };
195 UINT16 Length = 0;
196 UINT16 MaximumLength = 0;
197
198 WINPR_UNUSED(hints);
199 /* the structure is aligned on its Buffer pointer */
200 if (!winpr_ndr_decoder_read_align(context, s, 4) ||
201 !winpr_ndr_decoder_read_uint16(context, s, &Length) ||
202 !winpr_ndr_decoder_read_uint16(context, s, &MaximumLength) ||
203 !winpr_ndr_decoder_read_refpointer(context, s, &bufferDesc.ptrId) || Length > MaximumLength)
204 return FALSE;
205
206 res->lenHints.length = Length;
207 res->lenHints.maxLength = MaximumLength;
208 res->strLength = Length / 2;
209
210 return winpr_ndr_decoder_push_deferreds(context, &bufferDesc, 1);
211}
212
213static BOOL ndr_decoder_read_RPC_UNICODE_STRING_(WinPrNdrDecoder* context, wStream* s,
214 const void* hints, void* res)
215{
216 return ndr_decoder_read_RPC_UNICODE_STRING(context, s, hints, res);
217}
218
219BOOL ndr_encoder_write_RPC_UNICODE_STRING(WinPrNdrEncoder* context, wStream* s,
220 WINPR_ATTR_UNUSED const void* hints,
221 const RPC_UNICODE_STRING* res)
222{
223 WINPR_ASSERT(res);
224 if (!winpr_ndr_encoder_write_uint32(context, s, res->lenHints.length))
225 return FALSE;
226
227 if (!winpr_ndr_encoder_write_uint32(context, s, res->lenHints.maxLength))
228 return FALSE;
229
230 return winpr_ndr_encoder_write_data(context, s, res->Buffer, res->strLength);
231}
232
233static BOOL ndr_encoder_write_RPC_UNICODE_STRING_(WinPrNdrEncoder* context, wStream* s,
234 const void* hints, const void* pvres)
235{
236 const RPC_UNICODE_STRING* res = pvres;
237 return ndr_encoder_write_RPC_UNICODE_STRING(context, s, hints, res);
238}
239
240void ndr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel,
241 const RPC_UNICODE_STRING* obj)
242{
243 WINPR_UNUSED(indentLevel);
244 WLog_Print(logger, lvl, "\tLength=%" PRIu32 " MaximumLength=%" PRIu32, obj->lenHints.length,
245 obj->lenHints.maxLength);
246 winpr_HexLogDump(logger, lvl, obj->Buffer, obj->lenHints.length);
247}
248
249static void ndr_dump_RPC_UNICODE_STRING_(wLog* logger, UINT32 lvl, size_t indentLevel,
250 const void* obj)
251{
252 ndr_dump_RPC_UNICODE_STRING(logger, lvl, indentLevel, obj);
253}
254
255void ndr_destroy_RPC_UNICODE_STRING(const void* hints, RPC_UNICODE_STRING* obj)
256{
257 WINPR_UNUSED(hints);
258 if (!obj)
259 return;
260 winpr_ndr_pointer_release(obj->Buffer);
261 obj->Buffer = nullptr;
262}
263
264static void ndr_descr_destroy_RPC_UNICODE_STRING_(const void* hints, void* obj)
265{
266 ndr_destroy_RPC_UNICODE_STRING(hints, obj);
267}
268
269static const WinPrNdrMessageDescr RPC_UNICODE_STRING_descr_s = {
271 sizeof(RPC_UNICODE_STRING),
272 ndr_decoder_read_RPC_UNICODE_STRING_,
273 ndr_encoder_write_RPC_UNICODE_STRING_,
274 ndr_descr_destroy_RPC_UNICODE_STRING_,
275 ndr_dump_RPC_UNICODE_STRING_
276};
277
278WinPrNdrMessageType ndr_RPC_UNICODE_STRING_descr(void)
279{
280 return &RPC_UNICODE_STRING_descr_s;
281}
282
283/* ========================= RPC_UNICODE_STRING_Array ======================== */
284
285static BOOL ndr_decoder_read_RPC_UNICODE_STRING_Array(WinPrNdrDecoder* context, wStream* s,
286 const void* hints, void* v)
287{
288 WINPR_ASSERT(context);
289 WINPR_ASSERT(s);
290 WINPR_ASSERT(hints);
291 return winpr_ndr_decoder_read_uconformant_array(context, s, hints,
292 ndr_RPC_UNICODE_STRING_descr(), v);
293}
294
295static BOOL ndr_encoder_write_RPC_UNICODE_STRING_Array(WinPrNdrEncoder* context, wStream* s,
296 const void* ghints, const void* v)
297{
298 WINPR_ASSERT(context);
299 WINPR_ASSERT(s);
300 WINPR_ASSERT(ghints);
301
302 const WinPrNdrArrayHints* hints = (const WinPrNdrArrayHints*)ghints;
303
304 return winpr_ndr_encoder_write_uconformant_array(context, s, hints->count,
305 ndr_RPC_UNICODE_STRING_descr(), v);
306}
307
308static const WinPrNdrMessageDescr RPC_UNICODE_STRING_Array_descr_s = {
310 sizeof(RPC_UNICODE_STRING),
311 ndr_decoder_read_RPC_UNICODE_STRING_Array,
312 ndr_encoder_write_RPC_UNICODE_STRING_Array,
313 nullptr,
314 nullptr
315};
316
317static WinPrNdrMessageType ndr_RPC_UNICODE_STRING_Array_descr(void)
318{
319 return &RPC_UNICODE_STRING_Array_descr_s;
320}
321
322/* ========================== KERB_RPC_INTERNAL_NAME ======================== */
323
324BOOL ndr_decoder_read_KERB_RPC_INTERNAL_NAME(WinPrNdrDecoder* context, wStream* s,
325 const void* hints, KERB_RPC_INTERNAL_NAME* res)
326{
327 WINPR_ASSERT(res);
328
329 union
330 {
331 RPC_UNICODE_STRING** ppstr;
332 void* pv;
333 } cnv;
334 cnv.ppstr = &res->Names;
336 "KERB_RPC_INTERNAL_NAME.Names",
337 &res->nameHints,
338 cnv.pv,
339 TRUE,
340 ndr_RPC_UNICODE_STRING_Array_descr() };
341
342 UINT16 nameCount = 0;
343 WINPR_UNUSED(hints);
344
345 if (!winpr_ndr_decoder_read_uint16(context, s, &res->NameType) ||
346 !winpr_ndr_decoder_read_uint16(context, s, &nameCount))
347 return FALSE;
348
349 res->nameHints.count = nameCount;
350
351 return winpr_ndr_decoder_read_refpointer(context, s, &names.ptrId) &&
352 winpr_ndr_decoder_push_deferreds(context, &names, 1);
353}
354
355static BOOL ndr_descr_read_KERB_RPC_INTERNAL_NAME(WinPrNdrDecoder* context, wStream* s,
356 const void* hints, void* res)
357{
358 return ndr_decoder_read_KERB_RPC_INTERNAL_NAME(context, s, hints, res);
359}
360
361BOOL ndr_encoder_write_KERB_RPC_INTERNAL_NAME(WinPrNdrEncoder* context, wStream* s,
362 const void* hints, const KERB_RPC_INTERNAL_NAME* res)
363{
364 WINPR_UNUSED(context);
365 WINPR_UNUSED(s);
366 WINPR_UNUSED(hints);
367 WINPR_UNUSED(res);
368 WLog_ERR(TAG, "TODO: implement this");
369 return FALSE;
370}
371
372void ndr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel,
373 const KERB_RPC_INTERNAL_NAME* obj)
374{
375 WINPR_UNUSED(indentLevel);
376 WINPR_UNUSED(obj);
377 WLog_Print(logger, lvl, "TODO: implement this");
378}
379
380static void ndr_descr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel,
381 const void* obj)
382{
383 ndr_dump_KERB_RPC_INTERNAL_NAME(logger, lvl, indentLevel, obj);
384}
385
386void ndr_destroy_KERB_RPC_INTERNAL_NAME(const void* hints, KERB_RPC_INTERNAL_NAME* obj)
387{
388 WINPR_UNUSED(hints);
389 if (!obj)
390 return;
391
392 if (obj->Names)
393 {
394 for (UINT32 i = 0; i < obj->nameHints.count; i++)
395 ndr_destroy_RPC_UNICODE_STRING(nullptr, &obj->Names[i]);
396 }
397
398 winpr_ndr_pointer_release(obj->Names);
399 obj->Names = nullptr;
400 obj->nameHints.count = 0;
401}
402
403static void ndr_descr_destroy_KERB_RPC_INTERNAL_NAME(const void* hints, void* obj)
404{
405 ndr_destroy_KERB_RPC_INTERNAL_NAME(hints, obj);
406}
407
408static WinPrNdrMessageDescr KERB_RPC_INTERNAL_NAME_descr_s = {
411 ndr_descr_read_KERB_RPC_INTERNAL_NAME,
412 nullptr,
413 ndr_descr_destroy_KERB_RPC_INTERNAL_NAME,
414 ndr_descr_dump_KERB_RPC_INTERNAL_NAME
415};
416
417WinPrNdrMessageType ndr_KERB_RPC_INTERNAL_NAME_descr(void)
418{
419 return &KERB_RPC_INTERNAL_NAME_descr_s;
420}
421
422/* ========================== KERB_RPC_ENCRYPTION_KEY ======================== */
423
424static const WinPrNdrFieldStruct KERB_RPC_ENCRYPTION_KEY_fields[] = {
425 { "reserved1", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved1), WINPR_NDR_NOT_POINTER, -1,
426 &winpr_ndr_uint32_descr_s, 0, 0 },
427 { "reserved2", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved2), WINPR_NDR_NOT_POINTER, -1,
428 &winpr_ndr_uint32_descr_s, 0, 0 },
429 { "reserved3", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved3), WINPR_NDR_NOT_POINTER, -1,
430 &ndr_KERB_RPC_OCTET_STRING_descr_s, 0, 0 }
431};
432static const WinPrNdrStructDescr KERB_RPC_ENCRYPTION_KEY_struct = {
433 "KERB_RPC_ENCRYPTION_KEY", ARRAYSIZE(KERB_RPC_ENCRYPTION_KEY_fields),
434 KERB_RPC_ENCRYPTION_KEY_fields, 0
435};
436
437RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_ENCRYPTION_KEY)
438
439/* ========================== BuildEncryptedAuthDataReq ======================== */
440
441static const WinPrNdrFieldStruct BuildEncryptedAuthDataReq_fields[] = {
442 { "KeyUsage", offsetof(BuildEncryptedAuthDataReq, KeyUsage), WINPR_NDR_NOT_POINTER, -1,
443 &winpr_ndr_uint32_descr_s, 0, 0 },
444 { "key", offsetof(BuildEncryptedAuthDataReq, Key), WINPR_NDR_POINTER_NON_NULL, -1,
445 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
446 { "plainAuthData", offsetof(BuildEncryptedAuthDataReq, PlainAuthData),
447 WINPR_NDR_POINTER_NON_NULL, -1, &ndr_KERB_ASN1_DATA_descr_s, 0, 0 }
448};
449static const WinPrNdrStructDescr BuildEncryptedAuthDataReq_struct = {
450 "BuildEncryptedAuthDataReq", ARRAYSIZE(BuildEncryptedAuthDataReq_fields),
451 BuildEncryptedAuthDataReq_fields, 0
452};
453
454RDPEAR_SIMPLE_MESSAGE_TYPE(BuildEncryptedAuthDataReq)
455
456/* ========================== ComputeTgsChecksumReq ======================== */
457
458static const WinPrNdrFieldStruct ComputeTgsChecksumReq_fields[] = {
459 { "requestBody", offsetof(ComputeTgsChecksumReq, requestBody), WINPR_NDR_POINTER_NON_NULL, -1,
460 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
461 { "key", offsetof(ComputeTgsChecksumReq, Key), WINPR_NDR_POINTER_NON_NULL, -1,
462 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
463 { "ChecksumType", offsetof(ComputeTgsChecksumReq, ChecksumType), WINPR_NDR_NOT_POINTER, -1,
464 &winpr_ndr_uint32_descr_s, 0, 0 }
465};
466static const WinPrNdrStructDescr ComputeTgsChecksumReq_struct = {
467 "ComputeTgsChecksumReq", ARRAYSIZE(ComputeTgsChecksumReq_fields), ComputeTgsChecksumReq_fields,
468 0
469};
470
471RDPEAR_SIMPLE_MESSAGE_TYPE(ComputeTgsChecksumReq)
472
473/* ========================== CreateApReqAuthenticatorReq ======================== */
474
475static const WinPrNdrFieldStruct CreateApReqAuthenticatorReq_fields[] = {
476 { "EncryptionKey", offsetof(CreateApReqAuthenticatorReq, EncryptionKey),
477 WINPR_NDR_POINTER_NON_NULL, -1, &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
478 { "SequenceNumber", offsetof(CreateApReqAuthenticatorReq, SequenceNumber),
479 WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint32_descr_s, 0, 0 },
480 { "ClientName", offsetof(CreateApReqAuthenticatorReq, ClientName), WINPR_NDR_POINTER_NON_NULL,
481 -1, &KERB_RPC_INTERNAL_NAME_descr_s, 0, 0 },
482 { "ClientRealm", offsetof(CreateApReqAuthenticatorReq, ClientRealm), WINPR_NDR_POINTER_NON_NULL,
483 -1, &RPC_UNICODE_STRING_descr_s, 0, 0 },
484 { "SkewTime", offsetof(CreateApReqAuthenticatorReq, SkewTime), WINPR_NDR_POINTER_NON_NULL, -1,
485 &winpr_ndr_uint64_descr_s, 0, 0 },
486 { "SubKey", offsetof(CreateApReqAuthenticatorReq, SubKey), WINPR_NDR_POINTER, -1,
487 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
488 { "AuthData", offsetof(CreateApReqAuthenticatorReq, AuthData), WINPR_NDR_POINTER_NON_NULL, -1,
489 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
490 { "GssChecksum", offsetof(CreateApReqAuthenticatorReq, GssChecksum), WINPR_NDR_POINTER, -1,
491 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
492 { "KeyUsage", offsetof(CreateApReqAuthenticatorReq, KeyUsage), WINPR_NDR_NOT_POINTER, -1,
493 &winpr_ndr_uint32_descr_s, 0, 0 },
494};
495static const WinPrNdrStructDescr CreateApReqAuthenticatorReq_struct = {
496 "CreateApReqAuthenticatorReq", ARRAYSIZE(CreateApReqAuthenticatorReq_fields),
497 CreateApReqAuthenticatorReq_fields, 0
498};
499
500RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorReq)
501
502/* ========================== CreateApReqAuthenticatorResp ======================== */
503
504static const WinPrNdrFieldStruct CreateApReqAuthenticatorResp_fields[] = {
505 { "AuthenticatorTime", offsetof(CreateApReqAuthenticatorResp, AuthenticatorTime),
506 WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint64_descr_s, 0, 0 },
507 { "Authenticator", offsetof(CreateApReqAuthenticatorResp, Authenticator), WINPR_NDR_NOT_POINTER,
508 -1, &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
509 { "KerbProtocolError", offsetof(CreateApReqAuthenticatorResp, KerbProtocolError),
510 WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint32_descr_s, 0, 0 },
511};
512
513static const WinPrNdrStructDescr CreateApReqAuthenticatorResp_struct = {
514 "CreateApReqAuthenticatorResp", ARRAYSIZE(CreateApReqAuthenticatorResp_fields),
515 CreateApReqAuthenticatorResp_fields, 0
516};
517
518RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorResp)
519
520/* ========================== UnpackKdcReplyBodyReq ======================== */
521
522static const WinPrNdrFieldStruct UnpackKdcReplyBodyReq_fields[] = {
523 { "EncryptedData", offsetof(UnpackKdcReplyBodyReq, EncryptedData), WINPR_NDR_POINTER_NON_NULL,
524 -1, &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
525 { "Key", offsetof(UnpackKdcReplyBodyReq, Key), WINPR_NDR_POINTER_NON_NULL, -1,
526 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
527 { "StrenghtenKey", offsetof(UnpackKdcReplyBodyReq, StrengthenKey), WINPR_NDR_POINTER, -1,
528 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 },
529 { "Pdu", offsetof(UnpackKdcReplyBodyReq, Pdu), WINPR_NDR_NOT_POINTER, -1,
530 &winpr_ndr_uint32_descr_s, 0, 0 },
531 { "KeyUsage", offsetof(UnpackKdcReplyBodyReq, KeyUsage), WINPR_NDR_NOT_POINTER, -1,
532 &winpr_ndr_uint32_descr_s, 0, 0 },
533};
534
535static const WinPrNdrStructDescr UnpackKdcReplyBodyReq_struct = {
536 "UnpackKdcReplyBodyReq", ARRAYSIZE(UnpackKdcReplyBodyReq_fields), UnpackKdcReplyBodyReq_fields,
537 0
538};
539
540RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyReq)
541
542/* ========================== UnpackKdcReplyBodyResp ======================== */
543
544static const WinPrNdrFieldStruct UnpackKdcReplyBodyResp_fields[] = {
545 { "KerbProtocolError", offsetof(UnpackKdcReplyBodyResp, KerbProtocolError),
546 WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint32_descr_s, 0, 0 },
547 { "ReplyBody", offsetof(UnpackKdcReplyBodyResp, ReplyBody), WINPR_NDR_NOT_POINTER, -1,
548 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 }
549};
550
551static const WinPrNdrStructDescr UnpackKdcReplyBodyResp_struct = {
552 "UnpackKdcReplyBodyResp", ARRAYSIZE(UnpackKdcReplyBodyResp_fields),
553 UnpackKdcReplyBodyResp_fields, 0
554};
555
556RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyResp)
557
558/* ========================== DecryptApReplyReq ======================== */
559
560static const WinPrNdrFieldStruct DecryptApReplyReq_fields[] = {
561 { "EncryptedReply", offsetof(DecryptApReplyReq, EncryptedReply), WINPR_NDR_POINTER_NON_NULL, -1,
562 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
563 { "Key", offsetof(DecryptApReplyReq, Key), WINPR_NDR_POINTER_NON_NULL, -1,
564 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 }
565};
566
567static const WinPrNdrStructDescr DecryptApReplyReq_struct = { "DecryptApReplyReq",
568 ARRAYSIZE(DecryptApReplyReq_fields),
569 DecryptApReplyReq_fields, 0 };
570
571RDPEAR_SIMPLE_MESSAGE_TYPE(DecryptApReplyReq)
572
573/* ========================== PackApReplyReq ======================== */
574
575static const WinPrNdrFieldStruct PackApReplyReq_fields[] = {
576 { "Reply", offsetof(PackApReplyReq, Reply), WINPR_NDR_POINTER_NON_NULL, -1,
577 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
578 { "ReplyBody", offsetof(PackApReplyReq, ReplyBody), WINPR_NDR_POINTER_NON_NULL, -1,
579 &ndr_KERB_ASN1_DATA_descr_s, 0, 0 },
580 { "SessionKey", offsetof(PackApReplyReq, SessionKey), WINPR_NDR_POINTER_NON_NULL, -1,
581 &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s, 0, 0 }
582};
583
584static const WinPrNdrStructDescr PackApReplyReq_struct = { "PackApReplyReq",
585 ARRAYSIZE(PackApReplyReq_fields),
586 PackApReplyReq_fields, 0 };
587
588RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyReq)
589
590/* ========================== PackApReplyResp ======================== */
591
592static const WinPrNdrFieldStruct PackApReplyResp_fields[] = {
593 { "PackedReplySize", offsetof(PackApReplyResp, PackedReplyHints), WINPR_NDR_NOT_POINTER, -1,
594 &winpr_ndr_uint32_descr_s, 0, 0 },
595 { "PackedReply", offsetof(PackApReplyResp, PackedReply), WINPR_NDR_POINTER_NON_NULL, 0,
596 &winpr_ndr_uint8Array_descr_s, 0, 0 },
597};
598
599static const WinPrNdrStructDescr PackApReplyResp_struct = { "PackApReplyResp",
600 ARRAYSIZE(PackApReplyResp_fields),
601 PackApReplyResp_fields, 0 };
602
603RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyResp)
604
605/* ========================== messages ======================== */
606
607
608static BOOL rdpear_read_message(WinPrNdrDecoder* decoder, wStream* s,
609 const WinPrNdrStructDescr* descr, void* msg)
610{
611 WINPR_ASSERT(decoder);
612 WINPR_ASSERT(s);
613
614 wStream object = WINPR_C_ARRAY_INIT;
616 if (!winpr_ndr_decoder_read_object(decoder, s, &object) ||
617 !winpr_ndr_decoder_read_refpointer(decoder, &object, &refId))
618 return FALSE;
619
620 if (!refId)
621 {
622 WLog_ERR(TAG, "%s: null top-level pointer", descr->name);
623 return FALSE;
624 }
625
626 return winpr_ndr_decoder_read_fromDescr(decoder, &object, descr, msg) &&
627 winpr_ndr_decoder_treat_deferreds(decoder, &object);
628}
629
632static BOOL rdpear_write_message(WinPrNdrEncoder* encoder, wStream* s,
633 const WinPrNdrStructDescr* descr, const void* msg)
634{
635 WINPR_ASSERT(encoder);
636 WINPR_ASSERT(s);
637
638 return winpr_ndr_encoder_write_header(encoder, s) &&
639 winpr_ndr_encoder_start_object(encoder, s) &&
641 winpr_ndr_encoder_write_fromDescr(encoder, s, descr, msg) &&
644}
645
646#define RDPEAR_ARM(CALLID, NAME, DESCR) \
647 { CALLID, { #NAME, 0, WINPR_NDR_NOT_POINTER, -1, DESCR, 0, 0 } }
648
649/* the calls without a description are encoded without their arm */
650static const WinPrNdrUnionArm rdpear_default_arm = {
651 0, { "default", 0, WINPR_NDR_NOT_POINTER, -1, nullptr, 0, 0 }
652};
653
654/* ========================== KerbCredIsoRemoteInput ======================== */
655
656static const WinPrNdrUnionArm KerbCredIsoRemoteInputUnion_arms[] = {
657 RDPEAR_ARM(RemoteCallKerbNegotiateVersion, NegotiateVersion, &winpr_ndr_uint32_descr_s),
658 RDPEAR_ARM(RemoteCallKerbCreateApReqAuthenticator, CreateApReqAuthenticator,
659 &ndr_CreateApReqAuthenticatorReq_descr_s),
660 RDPEAR_ARM(RemoteCallKerbDecryptApReply, DecryptApReply, &ndr_DecryptApReplyReq_descr_s),
661 RDPEAR_ARM(RemoteCallKerbUnpackKdcReplyBody, UnpackKdcReplyBody,
662 &ndr_UnpackKdcReplyBodyReq_descr_s),
663 RDPEAR_ARM(RemoteCallKerbComputeTgsChecksum, ComputeTgsChecksum,
664 &ndr_ComputeTgsChecksumReq_descr_s),
665 RDPEAR_ARM(RemoteCallKerbBuildEncryptedAuthData, BuildEncryptedAuthData,
666 &ndr_BuildEncryptedAuthDataReq_descr_s),
667 RDPEAR_ARM(RemoteCallKerbPackApReply, PackApReply, &ndr_PackApReplyReq_descr_s),
668};
669
670static const WinPrNdrUnionDescr KerbCredIsoRemoteInputUnion_union = {
671 "KerbCredIsoRemoteInputUnion", ARRAYSIZE(KerbCredIsoRemoteInputUnion_arms),
672 KerbCredIsoRemoteInputUnion_arms, sizeof(UINT16), &rdpear_default_arm
673};
674
676
677static const WinPrNdrFieldStruct KerbCredIsoRemoteInput_fields[] = {
678 { "CallId", offsetof(KerbCredIsoRemoteInput, CallId), WINPR_NDR_NOT_POINTER, -1,
679 &winpr_ndr_uint16_descr_s, 0, 0 },
680 { "Input", offsetof(KerbCredIsoRemoteInput, Input), WINPR_NDR_NOT_POINTER, 0,
681 &KerbCredIsoRemoteInputUnion_descr_s, 0, 0 },
682};
683
684/* the largest arm alignment is the one of CreateApReqAuthenticator.AuthenticatorTime */
685static const WinPrNdrStructDescr KerbCredIsoRemoteInput_struct = {
686 "KerbCredIsoRemoteInput", ARRAYSIZE(KerbCredIsoRemoteInput_fields),
687 KerbCredIsoRemoteInput_fields, 8
688};
689
690BOOL rdpear_kerb_input_read(WinPrNdrDecoder* decoder, wStream* s, KerbCredIsoRemoteInput* input)
691{
692 WINPR_ASSERT(input);
693 return rdpear_read_message(decoder, s, &KerbCredIsoRemoteInput_struct, input);
694}
695
696void rdpear_kerb_input_free(KerbCredIsoRemoteInput* input)
697{
698 if (input)
699 winpr_ndr_struct_destroy(&KerbCredIsoRemoteInput_struct, input);
700}
701
702/* ========================== KerbCredIsoRemoteOutput ======================== */
703
704static const WinPrNdrUnionArm KerbCredIsoRemoteOutputUnion_arms[] = {
705 RDPEAR_ARM(RemoteCallKerbNegotiateVersion, NegotiateVersion, &winpr_ndr_uint32_descr_s),
706 RDPEAR_ARM(RemoteCallKerbCreateApReqAuthenticator, CreateApReqAuthenticator,
707 &ndr_CreateApReqAuthenticatorResp_descr_s),
708 RDPEAR_ARM(RemoteCallKerbDecryptApReply, DecryptApReply, &ndr_KERB_ASN1_DATA_descr_s),
709 RDPEAR_ARM(RemoteCallKerbUnpackKdcReplyBody, UnpackKdcReplyBody,
710 &ndr_UnpackKdcReplyBodyResp_descr_s),
711 RDPEAR_ARM(RemoteCallKerbComputeTgsChecksum, ComputeTgsChecksum, &ndr_KERB_ASN1_DATA_descr_s),
712 RDPEAR_ARM(RemoteCallKerbBuildEncryptedAuthData, BuildEncryptedAuthData,
713 &ndr_KERB_ASN1_DATA_descr_s),
714 RDPEAR_ARM(RemoteCallKerbPackApReply, PackApReply, &ndr_PackApReplyResp_descr_s),
715};
716
717static const WinPrNdrUnionDescr KerbCredIsoRemoteOutputUnion_union = {
718 "KerbCredIsoRemoteOutputUnion", ARRAYSIZE(KerbCredIsoRemoteOutputUnion_arms),
719 KerbCredIsoRemoteOutputUnion_arms, sizeof(UINT16), &rdpear_default_arm
720};
721
723
724static const WinPrNdrFieldStruct KerbCredIsoRemoteOutput_fields[] = {
725 { "CallId", offsetof(KerbCredIsoRemoteOutput, CallId), WINPR_NDR_NOT_POINTER, -1,
726 &winpr_ndr_uint16_descr_s, 0, 0 },
727 { "Status", offsetof(KerbCredIsoRemoteOutput, Status), WINPR_NDR_NOT_POINTER, -1,
728 &winpr_ndr_uint32_descr_s, 0, 0 },
729 { "Output", offsetof(KerbCredIsoRemoteOutput, Output), WINPR_NDR_NOT_POINTER, 0,
730 &KerbCredIsoRemoteOutputUnion_descr_s, 0, 0 },
731};
732
733static const WinPrNdrStructDescr KerbCredIsoRemoteOutput_struct = {
734 "KerbCredIsoRemoteOutput", ARRAYSIZE(KerbCredIsoRemoteOutput_fields),
735 KerbCredIsoRemoteOutput_fields, 8
736};
737
738BOOL rdpear_kerb_output_write(WinPrNdrEncoder* encoder, wStream* s,
739 const KerbCredIsoRemoteOutput* output)
740{
741 WINPR_ASSERT(output);
742 return rdpear_write_message(encoder, s, &KerbCredIsoRemoteOutput_struct, output);
743}
744
745void rdpear_kerb_output_free(KerbCredIsoRemoteOutput* output)
746{
747 if (output)
748 winpr_ndr_struct_destroy(&KerbCredIsoRemoteOutput_struct, output);
749}
750
751/* ========================== NTLM types ======================== */
752
753#define RDPEAR_BYTES_FIELD(TYPE, NAME, SIZE) \
754 { #NAME, offsetof(TYPE, NAME), WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint8_descr_s, SIZE, 0 }
755
757static BOOL ndr_decoder_read_uint16_count(WinPrNdrDecoder* context, wStream* s, const void* hints,
758 void* v)
759{
760 WINPR_UNUSED(hints);
761 UINT16 count = 0;
762 if (!winpr_ndr_decoder_read_uint16(context, s, &count))
763 return FALSE;
764 ((WinPrNdrArrayHints*)v)->count = count;
765 return TRUE;
766}
767
768static BOOL ndr_encoder_write_uint16_count(WinPrNdrEncoder* context, wStream* s, const void* hints,
769 const void* v)
770{
771 WINPR_UNUSED(hints);
772 const UINT32 count = ((const WinPrNdrArrayHints*)v)->count;
773 if (count > UINT16_MAX)
774 {
775 WLog_ERR(TAG, "count %" PRIu32 " doesn't fit in a USHORT", count);
776 return FALSE;
777 }
778 return winpr_ndr_encoder_write_uint16(context, s, (UINT16)count);
779}
780
781static const WinPrNdrMessageDescr ndr_uint16_count_descr_s = { WINPR_NDR_ARITY_SIMPLE,
782 sizeof(WinPrNdrArrayHints),
783 ndr_decoder_read_uint16_count,
784 ndr_encoder_write_uint16_count,
785 nullptr,
786 nullptr };
787
788static const WinPrNdrFieldStruct MSV1_0_REMOTE_ENCRYPTED_SECRETS_fields[] = {
789 { "reserved1", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved1), WINPR_NDR_NOT_POINTER, -1,
790 &winpr_ndr_uint8_descr_s, 0, 0 },
791 { "reserved2", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved2), WINPR_NDR_NOT_POINTER, -1,
792 &winpr_ndr_uint8_descr_s, 0, 0 },
793 { "reserved3", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved3), WINPR_NDR_NOT_POINTER, -1,
794 &winpr_ndr_uint8_descr_s, 0, 0 },
795 { "reserved4", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved4), WINPR_NDR_NOT_POINTER, -1,
796 &winpr_ndr_uint16_descr_s, 0, 0 },
797 RDPEAR_BYTES_FIELD(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved5,
798 RDPEAR_MSV1_0_CREDENTIAL_KEY_LENGTH),
799 { "reservedSize", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reservedSize),
800 WINPR_NDR_NOT_POINTER, -1, &winpr_ndr_uint32_descr_s, 0, 0 },
801 { "reserved6", offsetof(MSV1_0_REMOTE_ENCRYPTED_SECRETS, reserved6), WINPR_NDR_POINTER, 5,
802 &winpr_ndr_uint8Array_descr_s, 0, 0 },
803};
804
805static const WinPrNdrStructDescr MSV1_0_REMOTE_ENCRYPTED_SECRETS_struct = {
806 "MSV1_0_REMOTE_ENCRYPTED_SECRETS", ARRAYSIZE(MSV1_0_REMOTE_ENCRYPTED_SECRETS_fields),
807 MSV1_0_REMOTE_ENCRYPTED_SECRETS_fields, 4
808};
809
811
812static const WinPrNdrFieldStruct NT_CHALLENGE_fields[] = {
813 RDPEAR_BYTES_FIELD(NT_CHALLENGE, Data, RDPEAR_MSV1_0_CHALLENGE_LENGTH),
814};
815
816static const WinPrNdrStructDescr NT_CHALLENGE_struct = { "NT_CHALLENGE",
817 ARRAYSIZE(NT_CHALLENGE_fields),
818 NT_CHALLENGE_fields, 1 };
819
821
822static const WinPrNdrFieldStruct NT_RESPONSE_fields[] = {
823 RDPEAR_BYTES_FIELD(NT_RESPONSE, Data, RDPEAR_MSV1_0_RESPONSE_LENGTH),
824};
825
826static const WinPrNdrStructDescr NT_RESPONSE_struct = { "NT_RESPONSE",
827 ARRAYSIZE(NT_RESPONSE_fields),
828 NT_RESPONSE_fields, 1 };
829
831
832static const WinPrNdrFieldStruct USER_SESSION_KEY_fields[] = {
833 RDPEAR_BYTES_FIELD(USER_SESSION_KEY, Data, RDPEAR_MSV1_0_USER_SESSION_KEY_LENGTH),
834};
835
836static const WinPrNdrStructDescr USER_SESSION_KEY_struct = { "USER_SESSION_KEY",
837 ARRAYSIZE(USER_SESSION_KEY_fields),
838 USER_SESSION_KEY_fields, 1 };
839
841
842/* ========================== NTLM calls ======================== */
843
844static const WinPrNdrFieldStruct Lm20GetNtlm3ChallengeResponseReq_fields[] = {
845 { "Credential", offsetof(Lm20GetNtlm3ChallengeResponseReq, Credential), WINPR_NDR_POINTER, -1,
846 &MSV1_0_REMOTE_ENCRYPTED_SECRETS_descr_s, 0, 0 },
847 { "UserName", offsetof(Lm20GetNtlm3ChallengeResponseReq, UserName), WINPR_NDR_POINTER, -1,
848 &RPC_UNICODE_STRING_descr_s, 0, 0 },
849 { "LogonDomainName", offsetof(Lm20GetNtlm3ChallengeResponseReq, LogonDomainName),
850 WINPR_NDR_POINTER, -1, &RPC_UNICODE_STRING_descr_s, 0, 0 },
851 { "ServerName", offsetof(Lm20GetNtlm3ChallengeResponseReq, ServerName), WINPR_NDR_POINTER, -1,
852 &RPC_UNICODE_STRING_descr_s, 0, 0 },
853 RDPEAR_BYTES_FIELD(Lm20GetNtlm3ChallengeResponseReq, ChallengeToClient,
854 RDPEAR_MSV1_0_CHALLENGE_LENGTH),
855};
856
857static const WinPrNdrStructDescr Lm20GetNtlm3ChallengeResponseReq_struct = {
858 "Lm20GetNtlm3ChallengeResponseReq", ARRAYSIZE(Lm20GetNtlm3ChallengeResponseReq_fields),
859 Lm20GetNtlm3ChallengeResponseReq_fields, 4
860};
861
863
864static const WinPrNdrFieldStruct Lm20GetNtlm3ChallengeResponseResp_fields[] = {
865 { "Ntlm3ResponseLength", offsetof(Lm20GetNtlm3ChallengeResponseResp, Ntlm3ResponseLength),
866 WINPR_NDR_NOT_POINTER, -1, &ndr_uint16_count_descr_s, 0, 0 },
867 { "Ntlm3Response", offsetof(Lm20GetNtlm3ChallengeResponseResp, Ntlm3Response),
868 WINPR_NDR_POINTER, 0, &winpr_ndr_uint8Array_descr_s, 0, 0 },
869 RDPEAR_BYTES_FIELD(Lm20GetNtlm3ChallengeResponseResp, Lm3Response.Response,
870 RDPEAR_MSV1_0_NTLM3_RESPONSE_LENGTH),
871 RDPEAR_BYTES_FIELD(Lm20GetNtlm3ChallengeResponseResp, Lm3Response.ChallengeFromClient,
872 RDPEAR_MSV1_0_CHALLENGE_LENGTH),
873 RDPEAR_BYTES_FIELD(Lm20GetNtlm3ChallengeResponseResp, UserSessionKey.Data,
874 RDPEAR_MSV1_0_USER_SESSION_KEY_LENGTH),
875 RDPEAR_BYTES_FIELD(Lm20GetNtlm3ChallengeResponseResp, LmSessionKey.Data,
876 RDPEAR_MSV1_0_CHALLENGE_LENGTH),
877};
878
879static const WinPrNdrStructDescr Lm20GetNtlm3ChallengeResponseResp_struct = {
880 "Lm20GetNtlm3ChallengeResponseResp", ARRAYSIZE(Lm20GetNtlm3ChallengeResponseResp_fields),
881 Lm20GetNtlm3ChallengeResponseResp_fields, 4
882};
883
886
887static const WinPrNdrFieldStruct CalculateNtResponseReq_fields[] = {
888 { "NtChallenge", offsetof(CalculateNtResponseReq, NtChallenge), WINPR_NDR_POINTER, -1,
889 &NT_CHALLENGE_descr_s, 0, 0 },
890 { "Credential", offsetof(CalculateNtResponseReq, Credential), WINPR_NDR_POINTER, -1,
891 &MSV1_0_REMOTE_ENCRYPTED_SECRETS_descr_s, 0, 0 },
892};
893
894static const WinPrNdrStructDescr CalculateNtResponseReq_struct = {
895 "CalculateNtResponseReq", ARRAYSIZE(CalculateNtResponseReq_fields),
896 CalculateNtResponseReq_fields, 4
897};
898
900
901static const WinPrNdrFieldStruct CalculateUserSessionKeyNtReq_fields[] = {
902 { "NtResponse", offsetof(CalculateUserSessionKeyNtReq, NtResponse), WINPR_NDR_POINTER, -1,
903 &NT_RESPONSE_descr_s, 0, 0 },
904 { "Credential", offsetof(CalculateUserSessionKeyNtReq, Credential), WINPR_NDR_POINTER, -1,
905 &MSV1_0_REMOTE_ENCRYPTED_SECRETS_descr_s, 0, 0 },
906};
907
908static const WinPrNdrStructDescr CalculateUserSessionKeyNtReq_struct = {
909 "CalculateUserSessionKeyNtReq", ARRAYSIZE(CalculateUserSessionKeyNtReq_fields),
910 CalculateUserSessionKeyNtReq_fields, 4
911};
912
914
915static const WinPrNdrFieldStruct CompareCredentialsReq_fields[] = {
916 { "LhsCredential", offsetof(CompareCredentialsReq, LhsCredential), WINPR_NDR_POINTER, -1,
917 &MSV1_0_REMOTE_ENCRYPTED_SECRETS_descr_s, 0, 0 },
918 { "RhsCredential", offsetof(CompareCredentialsReq, RhsCredential), WINPR_NDR_POINTER, -1,
919 &MSV1_0_REMOTE_ENCRYPTED_SECRETS_descr_s, 0, 0 },
920};
921
922static const WinPrNdrStructDescr CompareCredentialsReq_struct = {
923 "CompareCredentialsReq", ARRAYSIZE(CompareCredentialsReq_fields), CompareCredentialsReq_fields,
924 4
925};
926
928
929static const WinPrNdrFieldStruct CompareCredentialsResp_fields[] = {
930 { "AreNtOwfsEqual", offsetof(CompareCredentialsResp, AreNtOwfsEqual), WINPR_NDR_NOT_POINTER, -1,
931 &winpr_ndr_uint32_descr_s, 0, 0 },
932 { "AreLmOwfsEqual", offsetof(CompareCredentialsResp, AreLmOwfsEqual), WINPR_NDR_NOT_POINTER, -1,
933 &winpr_ndr_uint32_descr_s, 0, 0 },
934 { "AreShaOwfsEqual", offsetof(CompareCredentialsResp, AreShaOwfsEqual), WINPR_NDR_NOT_POINTER,
935 -1, &winpr_ndr_uint32_descr_s, 0, 0 },
936};
937
938static const WinPrNdrStructDescr CompareCredentialsResp_struct = {
939 "CompareCredentialsResp", ARRAYSIZE(CompareCredentialsResp_fields),
940 CompareCredentialsResp_fields, 4
941};
942
944
945/* ========================== NtlmCredIsoRemoteInput ======================== */
946
947static const WinPrNdrUnionArm NtlmCredIsoRemoteInputUnion_arms[] = {
948 RDPEAR_ARM(RemoteCallNtlmNegotiateVersion, NegotiateVersion, &winpr_ndr_uint32_descr_s),
949 RDPEAR_ARM(RemoteCallNtlmLm20GetNtlm3ChallengeResponse, Lm20GetNtlm3ChallengeResponse,
950 &Lm20GetNtlm3ChallengeResponseReq_descr_s),
951 RDPEAR_ARM(RemoteCallNtlmCalculateNtResponse, CalculateNtResponse,
952 &CalculateNtResponseReq_descr_s),
953 RDPEAR_ARM(RemoteCallNtlmCalculateUserSessionKeyNt, CalculateUserSessionKeyNt,
954 &CalculateUserSessionKeyNtReq_descr_s),
955 RDPEAR_ARM(RemoteCallNtlmCompareCredentials, CompareCredentials,
956 &CompareCredentialsReq_descr_s),
957};
958
959static const WinPrNdrUnionDescr NtlmCredIsoRemoteInputUnion_union = {
960 "NtlmCredIsoRemoteInputUnion", ARRAYSIZE(NtlmCredIsoRemoteInputUnion_arms),
961 NtlmCredIsoRemoteInputUnion_arms, sizeof(UINT16), &rdpear_default_arm
962};
963
965
966static const WinPrNdrFieldStruct NtlmCredIsoRemoteInput_fields[] = {
967 { "CallId", offsetof(NtlmCredIsoRemoteInput, CallId), WINPR_NDR_NOT_POINTER, -1,
968 &winpr_ndr_uint16_descr_s, 0, 0 },
969 { "Input", offsetof(NtlmCredIsoRemoteInput, Input), WINPR_NDR_NOT_POINTER, 0,
970 &NtlmCredIsoRemoteInputUnion_descr_s, 0, 0 },
971};
972
973static const WinPrNdrStructDescr NtlmCredIsoRemoteInput_struct = {
974 "NtlmCredIsoRemoteInput", ARRAYSIZE(NtlmCredIsoRemoteInput_fields),
975 NtlmCredIsoRemoteInput_fields, 4
976};
977
978BOOL rdpear_ntlm_input_read(WinPrNdrDecoder* decoder, wStream* s, NtlmCredIsoRemoteInput* input)
979{
980 WINPR_ASSERT(input);
981 return rdpear_read_message(decoder, s, &NtlmCredIsoRemoteInput_struct, input);
982}
983
984void rdpear_ntlm_input_free(NtlmCredIsoRemoteInput* input)
985{
986 if (input)
987 winpr_ndr_struct_destroy(&NtlmCredIsoRemoteInput_struct, input);
988}
989
990/* ========================== NtlmCredIsoRemoteOutput ======================== */
991
992static const WinPrNdrUnionArm NtlmCredIsoRemoteOutputUnion_arms[] = {
993 RDPEAR_ARM(RemoteCallNtlmNegotiateVersion, NegotiateVersion, &winpr_ndr_uint32_descr_s),
994 RDPEAR_ARM(RemoteCallNtlmLm20GetNtlm3ChallengeResponse, Lm20GetNtlm3ChallengeResponse,
995 &Lm20GetNtlm3ChallengeResponseResp_descr_s),
996 RDPEAR_ARM(RemoteCallNtlmCalculateNtResponse, CalculateNtResponse, &NT_RESPONSE_descr_s),
997 RDPEAR_ARM(RemoteCallNtlmCalculateUserSessionKeyNt, CalculateUserSessionKeyNt,
998 &USER_SESSION_KEY_descr_s),
999 RDPEAR_ARM(RemoteCallNtlmCompareCredentials, CompareCredentials,
1000 &CompareCredentialsResp_descr_s),
1001};
1002
1003static const WinPrNdrUnionDescr NtlmCredIsoRemoteOutputUnion_union = {
1004 "NtlmCredIsoRemoteOutputUnion", ARRAYSIZE(NtlmCredIsoRemoteOutputUnion_arms),
1005 NtlmCredIsoRemoteOutputUnion_arms, sizeof(UINT16), &rdpear_default_arm
1006};
1007
1009
1010static const WinPrNdrFieldStruct NtlmCredIsoRemoteOutput_fields[] = {
1011 { "CallId", offsetof(NtlmCredIsoRemoteOutput, CallId), WINPR_NDR_NOT_POINTER, -1,
1012 &winpr_ndr_uint16_descr_s, 0, 0 },
1013 { "Status", offsetof(NtlmCredIsoRemoteOutput, Status), WINPR_NDR_NOT_POINTER, -1,
1014 &winpr_ndr_uint32_descr_s, 0, 0 },
1015 { "Output", offsetof(NtlmCredIsoRemoteOutput, Output), WINPR_NDR_NOT_POINTER, 0,
1016 &NtlmCredIsoRemoteOutputUnion_descr_s, 0, 0 },
1017};
1018
1019static const WinPrNdrStructDescr NtlmCredIsoRemoteOutput_struct = {
1020 "NtlmCredIsoRemoteOutput", ARRAYSIZE(NtlmCredIsoRemoteOutput_fields),
1021 NtlmCredIsoRemoteOutput_fields, 4
1022};
1023
1024BOOL rdpear_ntlm_output_write(WinPrNdrEncoder* encoder, wStream* s,
1025 const NtlmCredIsoRemoteOutput* output)
1026{
1027 WINPR_ASSERT(output);
1028 return rdpear_write_message(encoder, s, &NtlmCredIsoRemoteOutput_struct, output);
1029}
1030
1031void rdpear_ntlm_output_free(NtlmCredIsoRemoteOutput* output)
1032{
1033 if (output)
1034 winpr_ndr_struct_destroy(&NtlmCredIsoRemoteOutput_struct, output);
1035}
NDR encoder and decoder ([C706] chapter 14, [MS-RPCE] 2.2.5 and 2.2.6).
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_end_object(WinPrNdrEncoder *context, wStream *s)
ends the serialized object started with winpr_ndr_encoder_start_object()
Definition ndr.c:282
UINT32 winpr_ndr_refid
a referent id, the wire value of a pointer (WINPR_NDR_PTR_NULL for a null pointer)
Definition ndr.h:230
@ WINPR_NDR_NOT_POINTER
Definition ndr.h:313
@ WINPR_NDR_POINTER
Definition ndr.h:316
@ WINPR_NDR_POINTER_NON_NULL
Definition ndr.h:315
const char * name
Definition ndr.h:344
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_write_header(WinPrNdrEncoder *context, wStream *s)
writes the common type header ([MS-RPCE] 2.2.6.1): version, endianness, header length and filler
Definition ndr.c:224
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_read_uconformant_array(WinPrNdrDecoder *context, wStream *s, const WinPrNdrArrayHints *hints, WinPrNdrMessageType itemType, void *vtarget)
reads a conformant array: its count and the items
Definition ndr.c:1361
winpr_ndr_refid ptrId
Definition ndr.h:383
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_read_fromDescr(WinPrNdrDecoder *context, wStream *s, const WinPrNdrStructDescr *descr, void *target)
reads a structure from its descriptor
Definition ndr.c:1695
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_write_data(WinPrNdrEncoder *context, wStream *s, const void *data, size_t sz)
writes raw bytes, without alignment
Definition ndr.c:1094
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_treat_deferreds(WinPrNdrEncoder *context, wStream *s)
writes the pending deferred referents
Definition ndr.c:1075
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_write_toplevel_refid(WinPrNdrEncoder *context, wStream *s)
writes a new referent id for a non-null top-level pointer
Definition ndr.c:317
const WinPrNdrMessageDescr * WinPrNdrMessageType
a message type, a pointer on its descriptor
Definition ndr.h:306
@ WINPR_NDR_ARITY_SIMPLE
Definition ndr.h:280
@ WINPR_NDR_ARITY_ARRAYOF
Definition ndr.h:281
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_read_refpointer(WinPrNdrDecoder *context, wStream *s, UINT32 *refId)
reads a referent id
Definition ndr.c:1194
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_read_align(WinPrNdrDecoder *context, wStream *s, size_t sz)
skips the padding to align the current object offset
Definition ndr.c:1176
WINPR_API void winpr_ndr_pointer_release(void *ptr)
releases a referent
Definition ndr.c:1483
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_read_object(WinPrNdrDecoder *context, wStream *s, wStream *object)
reads the private header of a serialized object ([MS-RPCE] 2.2.6 type serialization version 1)
Definition ndr.c:1199
#define WINPR_NDR_UNION_MESSAGE_DEFINE(PREFIX, CTYPE)
defines a static message type for a non-encapsulated union
Definition ndr.h:186
WINPR_API void winpr_ndr_struct_destroy(const WinPrNdrStructDescr *descr, void *pptr)
releases the content of a structure from its descriptor
Definition ndr.c:2005
UINT32 count
Definition ndr.h:554
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_write_fromDescr(WinPrNdrEncoder *context, wStream *s, const WinPrNdrStructDescr *descr, const void *src)
writes a structure from its descriptor
Definition ndr.c:1032
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_push_deferreds(WinPrNdrDecoder *context, WinPrNdrDeferredEntry *deferreds, size_t ndeferred)
adds deferred pointers, read by the next winpr_ndr_decoder_treat_deferreds()
Definition ndr.c:1803
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_write_uconformant_array(WinPrNdrEncoder *context, wStream *s, UINT32 len, WinPrNdrMessageType itemType, const BYTE *ptr)
writes a conformant array: its count and the items
Definition ndr.c:935
#define WINPR_NDR_STRUCT_MESSAGE_DEFINE(PREFIX, CTYPE)
defines a static message type for a structure
Definition ndr.h:120
#define WINPR_NDR_PTR_NULL
the referent id of a null pointer
Definition ndr.h:48
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_encoder_start_object(WinPrNdrEncoder *context, wStream *s)
starts a serialized object ([MS-RPCE] 2.2.6 type serialization version 1)
Definition ndr.c:259
WINPR_ATTR_NODISCARD WINPR_API BOOL winpr_ndr_decoder_treat_deferreds(WinPrNdrDecoder *context, wStream *s)
reads the pending deferred referents
Definition ndr.c:1714
hints for a conformant array
Definition ndr.h:553
a deferred pointer, a referent to read after the current construct
Definition ndr.h:382
descriptor of a field in a structure
Definition ndr.h:328
message descriptor
Definition ndr.h:294
structure descriptor
Definition ndr.h:343
an arm of a non-encapsulated union
Definition ndr.h:354
a non-encapsulated union ([switch_type()])
Definition ndr.h:368
2.2.2.1.8 BuildEncryptedAuthData
2.2.2.2.3 CalculateNtResponse
2.2.2.2.4 CalculateUserSessionKeyNt
2.2.2.2.5 CompareCredentials
2.2.2.1.7 ComputeTgsChecksum
2.2.2.1.4 CreateApReqAuthenticator
2.2.2.1.4 CreateApReqAuthenticator
2.2.1.2.1 KERB_ASN1_DATA
2.2.1.2.8 KERB_RPC_ENCRYPTION_KEY
2.2.1.2.3 KERB_RPC_INTERNAL_NAME
2.2.1.2.2 KERB_RPC_OCTET_STRING
2.2.2.2.2 Lm20GetNtlm3ChallengeResponse
2.2.1.3.6 MSV1_0_REMOTE_ENCRYPTED_SECRETS, opaque for the CredSSP server
2.2.1.3.1 NT_CHALLENGE, also LM_SESSION_KEY
2.2.1.3.2 NT_RESPONSE
2.3.10 RPC_UNICODE_STRING (MS-DTYP)
2.2.1.3.4 USER_SESSION_KEY
2.2.2.1.6 UnpackKdcReplyBody
2.2.2.1.6 UnpackKdcReplyBody
2.2.1.2.9 KerbCredIsoRemoteInput
2.2.1.2.10 KerbCredIsoRemoteOutput
2.2.1.3.7 NtlmCredIsoRemoteInput
2.2.1.3.8 NtlmCredIsoRemoteOutput