Coverage Report

Created: 2026-09-14 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/channels/rdpear/common/rdpear_common.c
Line
Count
Source
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 *
4
 * Copyright 2023 David Fort <contact@hardening-consulting.com>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
#include <rdpear-common/rdpear_common.h>
20
#include <rdpear-common/rdpear_asn1.h>
21
#include <rdpear-common/ndr.h>
22
23
#include <stddef.h>
24
#include <winpr/print.h>
25
#include <freerdp/channels/log.h>
26
27
#define TAG CHANNELS_TAG("rdpear")
28
29
static char kerberosPackageName[] = {
30
  'K', 0, 'e', 0, 'r', 0, 'b', 0, 'e', 0, 'r', 0, 'o', 0, 's', 0
31
};
32
static char ntlmPackageName[] = { 'N', 0, 'T', 0, 'L', 0, 'M', 0 };
33
34
RdpEarPackageType rdpear_packageType_from_name(const WinPrAsn1_OctetString* package)
35
0
{
36
0
  if (package->len == sizeof(kerberosPackageName) &&
37
0
      memcmp(package->data, kerberosPackageName, package->len) == 0)
38
0
    return RDPEAR_PACKAGE_KERBEROS;
39
40
0
  if (package->len == sizeof(ntlmPackageName) &&
41
0
      memcmp(package->data, ntlmPackageName, package->len) == 0)
42
0
    return RDPEAR_PACKAGE_NTLM;
43
44
0
  return RDPEAR_PACKAGE_UNKNOWN;
45
0
}
46
47
wStream* rdpear_encodePayload(BOOL isKerb, wStream* payload)
48
0
{
49
0
  wStream* ret = nullptr;
50
0
  WinPrAsn1Encoder* enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
51
0
  if (!enc)
52
0
    return nullptr;
53
54
  /* TSRemoteGuardInnerPacket ::= SEQUENCE { */
55
0
  if (!WinPrAsn1EncSeqContainer(enc))
56
0
    goto out;
57
58
  /* packageName [1] OCTET STRING */
59
0
  WinPrAsn1_OctetString packageOctetString;
60
0
  if (isKerb)
61
0
  {
62
0
    packageOctetString.data = (BYTE*)kerberosPackageName;
63
0
    packageOctetString.len = sizeof(kerberosPackageName);
64
0
  }
65
0
  else
66
0
  {
67
0
    packageOctetString.data = (BYTE*)ntlmPackageName;
68
0
    packageOctetString.len = sizeof(ntlmPackageName);
69
0
  }
70
71
0
  if (!WinPrAsn1EncContextualOctetString(enc, 1, &packageOctetString))
72
0
    goto out;
73
74
  /* buffer [2] OCTET STRING*/
75
0
  WinPrAsn1_OctetString payloadOctetString = { Stream_GetPosition(payload),
76
0
                                             Stream_Buffer(payload) };
77
0
  if (!WinPrAsn1EncContextualOctetString(enc, 2, &payloadOctetString))
78
0
    goto out;
79
80
  /* } */
81
0
  if (!WinPrAsn1EncEndContainer(enc))
82
0
    goto out;
83
84
0
  ret = Stream_New(nullptr, 100);
85
0
  if (!ret)
86
0
    goto out;
87
88
0
  if (!WinPrAsn1EncToStream(enc, ret))
89
0
  {
90
0
    Stream_Free(ret, TRUE);
91
0
    ret = nullptr;
92
0
    goto out;
93
0
  }
94
0
out:
95
0
  WinPrAsn1Encoder_Free(&enc);
96
0
  return ret;
97
0
}
98
99
#define RDPEAR_SIMPLE_MESSAGE_TYPE(V)                                                             \
100
  BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj)                 \
101
0
  {                                                                                             \
102
0
    WINPR_UNUSED(hints);                                                                      \
103
0
    return ndr_struct_read_fromDescr(context, s, &V##_struct, obj);                           \
104
0
  }                                                                                             \
Unexecuted instantiation: ndr_read_KERB_RPC_OCTET_STRING
Unexecuted instantiation: ndr_read_KERB_ASN1_DATA
Unexecuted instantiation: ndr_read_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: ndr_read_BuildEncryptedAuthDataReq
Unexecuted instantiation: ndr_read_ComputeTgsChecksumReq
Unexecuted instantiation: ndr_read_CreateApReqAuthenticatorReq
Unexecuted instantiation: ndr_read_CreateApReqAuthenticatorResp
Unexecuted instantiation: ndr_read_UnpackKdcReplyBodyReq
Unexecuted instantiation: ndr_read_UnpackKdcReplyBodyResp
Unexecuted instantiation: ndr_read_DecryptApReplyReq
Unexecuted instantiation: ndr_read_PackApReplyReq
Unexecuted instantiation: ndr_read_PackApReplyResp
105
  BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, const V* obj)          \
106
0
  {                                                                                             \
107
0
    WINPR_UNUSED(hints);                                                                      \
108
0
    return ndr_struct_write_fromDescr(context, s, &V##_struct, obj);                          \
109
0
  }                                                                                             \
Unexecuted instantiation: ndr_write_KERB_RPC_OCTET_STRING
Unexecuted instantiation: ndr_write_KERB_ASN1_DATA
Unexecuted instantiation: ndr_write_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: ndr_write_BuildEncryptedAuthDataReq
Unexecuted instantiation: ndr_write_ComputeTgsChecksumReq
Unexecuted instantiation: ndr_write_CreateApReqAuthenticatorReq
Unexecuted instantiation: ndr_write_CreateApReqAuthenticatorResp
Unexecuted instantiation: ndr_write_UnpackKdcReplyBodyReq
Unexecuted instantiation: ndr_write_UnpackKdcReplyBodyResp
Unexecuted instantiation: ndr_write_DecryptApReplyReq
Unexecuted instantiation: ndr_write_PackApReplyReq
Unexecuted instantiation: ndr_write_PackApReplyResp
110
  void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj)                          \
111
0
  {                                                                                             \
112
0
    WINPR_UNUSED(hints);                                                                      \
113
0
    ndr_struct_destroy(context, &V##_struct, obj);                                            \
114
0
  }                                                                                             \
Unexecuted instantiation: ndr_destroy_KERB_RPC_OCTET_STRING
Unexecuted instantiation: ndr_destroy_KERB_ASN1_DATA
Unexecuted instantiation: ndr_destroy_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: ndr_destroy_BuildEncryptedAuthDataReq
Unexecuted instantiation: ndr_destroy_ComputeTgsChecksumReq
Unexecuted instantiation: ndr_destroy_CreateApReqAuthenticatorReq
Unexecuted instantiation: ndr_destroy_CreateApReqAuthenticatorResp
Unexecuted instantiation: ndr_destroy_UnpackKdcReplyBodyReq
Unexecuted instantiation: ndr_destroy_UnpackKdcReplyBodyResp
Unexecuted instantiation: ndr_destroy_DecryptApReplyReq
Unexecuted instantiation: ndr_destroy_PackApReplyReq
Unexecuted instantiation: ndr_destroy_PackApReplyResp
115
  void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj)                 \
116
0
  {                                                                                             \
117
0
    ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj);                    \
118
0
  }                                                                                             \
Unexecuted instantiation: ndr_dump_KERB_RPC_OCTET_STRING
Unexecuted instantiation: ndr_dump_KERB_ASN1_DATA
Unexecuted instantiation: ndr_dump_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: ndr_dump_BuildEncryptedAuthDataReq
Unexecuted instantiation: ndr_dump_ComputeTgsChecksumReq
Unexecuted instantiation: ndr_dump_CreateApReqAuthenticatorReq
Unexecuted instantiation: ndr_dump_CreateApReqAuthenticatorResp
Unexecuted instantiation: ndr_dump_UnpackKdcReplyBodyReq
Unexecuted instantiation: ndr_dump_UnpackKdcReplyBodyResp
Unexecuted instantiation: ndr_dump_DecryptApReplyReq
Unexecuted instantiation: ndr_dump_PackApReplyReq
Unexecuted instantiation: ndr_dump_PackApReplyResp
119
                                                                                                  \
120
  static BOOL ndr_descr_read_##V(NdrContext* context, wStream* s, const void* hints, void* obj) \
121
0
  {                                                                                             \
122
0
    WINPR_UNUSED(hints);                                                                      \
123
0
    return ndr_struct_read_fromDescr(context, s, &V##_struct, obj);                           \
124
0
  }                                                                                             \
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_KERB_RPC_OCTET_STRING
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_KERB_ASN1_DATA
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_BuildEncryptedAuthDataReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_ComputeTgsChecksumReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_CreateApReqAuthenticatorReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_CreateApReqAuthenticatorResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_UnpackKdcReplyBodyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_UnpackKdcReplyBodyResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_DecryptApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_PackApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_read_PackApReplyResp
125
  static BOOL ndr_descr_write_##V(NdrContext* context, wStream* s, const void* hints,           \
126
                                  const void* obj)                                              \
127
0
  {                                                                                             \
128
0
    WINPR_UNUSED(hints);                                                                      \
129
0
    return ndr_struct_write_fromDescr(context, s, &V##_struct, obj);                          \
130
0
  }                                                                                             \
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_KERB_RPC_OCTET_STRING
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_KERB_ASN1_DATA
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_BuildEncryptedAuthDataReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_ComputeTgsChecksumReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_CreateApReqAuthenticatorReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_CreateApReqAuthenticatorResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_UnpackKdcReplyBodyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_UnpackKdcReplyBodyResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_DecryptApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_PackApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_write_PackApReplyResp
131
  static void ndr_descr_destroy_##V(NdrContext* context, const void* hints, void* obj)          \
132
0
  {                                                                                             \
133
0
    WINPR_UNUSED(hints);                                                                      \
134
0
    ndr_struct_destroy(context, &V##_struct, obj);                                            \
135
0
  }                                                                                             \
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_KERB_RPC_OCTET_STRING
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_KERB_ASN1_DATA
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_BuildEncryptedAuthDataReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_ComputeTgsChecksumReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_CreateApReqAuthenticatorReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_CreateApReqAuthenticatorResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_UnpackKdcReplyBodyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_UnpackKdcReplyBodyResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_DecryptApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_PackApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_destroy_PackApReplyResp
136
  static void ndr_descr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const void* obj) \
137
0
  {                                                                                             \
138
0
    ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj);                    \
139
0
  }                                                                                             \
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_KERB_RPC_OCTET_STRING
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_KERB_ASN1_DATA
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_KERB_RPC_ENCRYPTION_KEY
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_BuildEncryptedAuthDataReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_ComputeTgsChecksumReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_CreateApReqAuthenticatorReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_CreateApReqAuthenticatorResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_UnpackKdcReplyBodyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_UnpackKdcReplyBodyResp
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_DecryptApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_PackApReplyReq
Unexecuted instantiation: rdpear_common.c:ndr_descr_dump_PackApReplyResp
140
                                                                                                  \
141
  static NdrMessageDescr ndr_##V##_descr_s = {                                                  \
142
    NDR_ARITY_SIMPLE,      sizeof(V),          ndr_descr_read_##V, ndr_descr_write_##V,       \
143
    ndr_descr_destroy_##V, ndr_descr_dump_##V,                                                \
144
  };                                                                                            \
145
                                                                                                  \
146
  NdrMessageType ndr_##V##_descr(void)                                                          \
147
0
  {                                                                                             \
148
0
    return &ndr_##V##_descr_s;                                                                \
149
0
  }
Unexecuted instantiation: ndr_KERB_RPC_OCTET_STRING_descr
Unexecuted instantiation: ndr_KERB_ASN1_DATA_descr
Unexecuted instantiation: ndr_KERB_RPC_ENCRYPTION_KEY_descr
Unexecuted instantiation: ndr_BuildEncryptedAuthDataReq_descr
Unexecuted instantiation: ndr_ComputeTgsChecksumReq_descr
Unexecuted instantiation: ndr_CreateApReqAuthenticatorReq_descr
Unexecuted instantiation: ndr_CreateApReqAuthenticatorResp_descr
Unexecuted instantiation: ndr_UnpackKdcReplyBodyReq_descr
Unexecuted instantiation: ndr_UnpackKdcReplyBodyResp_descr
Unexecuted instantiation: ndr_DecryptApReplyReq_descr
Unexecuted instantiation: ndr_PackApReplyReq_descr
Unexecuted instantiation: ndr_PackApReplyResp_descr
150
151
static const NdrFieldStruct KERB_RPC_OCTET_STRING_fields[] = {
152
  { "Length", offsetof(KERB_RPC_OCTET_STRING, length), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s },
153
  { "value", offsetof(KERB_RPC_OCTET_STRING, value), NDR_POINTER_NON_NULL, 0,
154
    &ndr_uint8Array_descr_s }
155
};
156
static const NdrStructDescr KERB_RPC_OCTET_STRING_struct = { "KERB_RPC_OCTET_STRING", 2,
157
                                                           KERB_RPC_OCTET_STRING_fields };
158
159
RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_OCTET_STRING)
160
161
/* ============================= KERB_ASN1_DATA ============================== */
162
163
static const NdrFieldStruct KERB_ASN1_DATA_fields[] = {
164
  { "Pdu", offsetof(KERB_ASN1_DATA, Pdu), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s },
165
  { "Count", offsetof(KERB_ASN1_DATA, Asn1BufferHints.count), NDR_NOT_POINTER, -1,
166
    &ndr_uint32_descr_s },
167
  { "Asn1Buffer", offsetof(KERB_ASN1_DATA, Asn1Buffer), NDR_POINTER_NON_NULL, 1,
168
    &ndr_uint8Array_descr_s }
169
};
170
static const NdrStructDescr KERB_ASN1_DATA_struct = { "KERB_ASN1_DATA",
171
                                                    ARRAYSIZE(KERB_ASN1_DATA_fields),
172
                                                    KERB_ASN1_DATA_fields };
173
174
RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_ASN1_DATA)
175
176
/* ============================ RPC_UNICODE_STRING ========================== */
177
178
BOOL ndr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints,
179
                                 RPC_UNICODE_STRING* res)
180
0
{
181
0
  NdrDeferredEntry bufferDesc = { NDR_PTR_NULL, "RPC_UNICODE_STRING.Buffer", &res->lenHints,
182
0
                                (void*)&res->Buffer, ndr_uint16VaryingArray_descr() };
183
0
  UINT16 Length = 0;
184
0
  UINT16 MaximumLength = 0;
185
186
0
  WINPR_UNUSED(hints);
187
0
  if (!ndr_read_uint16(context, s, &Length) || !ndr_read_uint16(context, s, &MaximumLength) ||
188
0
      !ndr_read_refpointer(context, s, &bufferDesc.ptrId) || Length > MaximumLength)
189
0
    return FALSE;
190
191
0
  res->lenHints.length = Length;
192
0
  res->lenHints.maxLength = MaximumLength;
193
0
  res->strLength = Length / 2;
194
195
0
  return ndr_push_deferreds(context, &bufferDesc, 1);
196
0
}
197
198
static BOOL ndr_descr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints,
199
                                              void* res)
200
0
{
201
0
  return ndr_read_RPC_UNICODE_STRING(context, s, hints, res);
202
0
}
203
204
BOOL ndr_write_RPC_UNICODE_STRING(NdrContext* context, wStream* s,
205
                                  WINPR_ATTR_UNUSED const void* hints,
206
                                  const RPC_UNICODE_STRING* res)
207
0
{
208
0
  WINPR_ASSERT(res);
209
0
  if (!ndr_write_uint32(context, s, res->lenHints.length))
210
0
    return FALSE;
211
212
0
  if (!ndr_write_uint32(context, s, res->lenHints.maxLength))
213
0
    return FALSE;
214
215
0
  return ndr_write_data(context, s, res->Buffer, res->strLength);
216
0
}
217
218
static BOOL ndr_write_RPC_UNICODE_STRING_(NdrContext* context, wStream* s, const void* hints,
219
                                          const void* pvres)
220
0
{
221
0
  const RPC_UNICODE_STRING* res = pvres;
222
0
  return ndr_write_RPC_UNICODE_STRING(context, s, hints, res);
223
0
}
224
225
void ndr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel,
226
                                 const RPC_UNICODE_STRING* obj)
227
0
{
228
0
  WINPR_UNUSED(indentLevel);
229
0
  WLog_Print(logger, lvl, "\tLength=%u MaximumLength=%u", obj->lenHints.length,
230
0
             obj->lenHints.maxLength);
231
0
  winpr_HexLogDump(logger, lvl, obj->Buffer, obj->lenHints.length);
232
0
}
233
234
static void ndr_descr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel,
235
                                              const void* obj)
236
0
{
237
0
  ndr_dump_RPC_UNICODE_STRING(logger, lvl, indentLevel, obj);
238
0
}
239
240
void ndr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void* hints, RPC_UNICODE_STRING* obj)
241
0
{
242
0
  WINPR_UNUSED(context);
243
0
  WINPR_UNUSED(hints);
244
0
  if (!obj)
245
0
    return;
246
0
  free(obj->Buffer);
247
0
  obj->Buffer = nullptr;
248
0
}
249
250
static void ndr_descr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void* hints, void* obj)
251
0
{
252
0
  ndr_destroy_RPC_UNICODE_STRING(context, hints, obj);
253
0
}
254
255
static const NdrMessageDescr RPC_UNICODE_STRING_descr_s = { NDR_ARITY_SIMPLE,
256
                                                          sizeof(RPC_UNICODE_STRING),
257
                                                          ndr_descr_read_RPC_UNICODE_STRING,
258
                                                          ndr_write_RPC_UNICODE_STRING_,
259
                                                          ndr_descr_destroy_RPC_UNICODE_STRING,
260
                                                          ndr_descr_dump_RPC_UNICODE_STRING };
261
262
NdrMessageType ndr_RPC_UNICODE_STRING_descr(void)
263
0
{
264
0
  return &RPC_UNICODE_STRING_descr_s;
265
0
}
266
267
/* ========================= RPC_UNICODE_STRING_Array ======================== */
268
269
static BOOL ndr_read_RPC_UNICODE_STRING_Array(NdrContext* context, wStream* s, const void* hints,
270
                                              void* v)
271
0
{
272
0
  WINPR_ASSERT(context);
273
0
  WINPR_ASSERT(s);
274
0
  WINPR_ASSERT(hints);
275
0
  return ndr_read_uconformant_array(context, s, hints, ndr_RPC_UNICODE_STRING_descr(), v);
276
0
}
277
278
static BOOL ndr_write_RPC_UNICODE_STRING_Array(NdrContext* context, wStream* s, const void* ghints,
279
                                               const void* v)
280
0
{
281
0
  WINPR_ASSERT(context);
282
0
  WINPR_ASSERT(s);
283
0
  WINPR_ASSERT(ghints);
284
285
0
  const NdrArrayHints* hints = (const NdrArrayHints*)ghints;
286
287
0
  return ndr_write_uconformant_array(context, s, hints->count, ndr_RPC_UNICODE_STRING_descr(), v);
288
0
}
289
290
static const NdrMessageDescr RPC_UNICODE_STRING_Array_descr_s = {
291
  NDR_ARITY_ARRAYOF,
292
  sizeof(RPC_UNICODE_STRING),
293
  ndr_read_RPC_UNICODE_STRING_Array,
294
  ndr_write_RPC_UNICODE_STRING_Array,
295
  nullptr,
296
  nullptr
297
};
298
299
static NdrMessageType ndr_RPC_UNICODE_STRING_Array_descr(void)
300
0
{
301
0
  return &RPC_UNICODE_STRING_Array_descr_s;
302
0
}
303
304
/* ========================== KERB_RPC_INTERNAL_NAME ======================== */
305
306
BOOL ndr_read_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, const void* hints,
307
                                     KERB_RPC_INTERNAL_NAME* res)
308
0
{
309
0
  WINPR_ASSERT(res);
310
311
0
  union
312
0
  {
313
0
    RPC_UNICODE_STRING** ppstr;
314
0
    void* pv;
315
0
  } cnv;
316
0
  cnv.ppstr = &res->Names;
317
0
  NdrDeferredEntry names = { NDR_PTR_NULL, "KERB_RPC_INTERNAL_NAME.Names", &res->nameHints,
318
0
                           cnv.pv, ndr_RPC_UNICODE_STRING_Array_descr() };
319
0
  UINT16 nameCount = 0;
320
0
  WINPR_UNUSED(hints);
321
322
0
  if (!ndr_read_uint16(context, s, &res->NameType) || !ndr_read_uint16(context, s, &nameCount))
323
0
    return FALSE;
324
325
0
  res->nameHints.count = nameCount;
326
327
0
  return ndr_read_refpointer(context, s, &names.ptrId) && ndr_push_deferreds(context, &names, 1);
328
0
}
329
330
static BOOL ndr_descr_read_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s,
331
                                                  const void* hints, void* res)
332
0
{
333
0
  return ndr_read_KERB_RPC_INTERNAL_NAME(context, s, hints, res);
334
0
}
335
336
BOOL ndr_write_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, const void* hints,
337
                                      const KERB_RPC_INTERNAL_NAME* res)
338
0
{
339
0
  WINPR_UNUSED(context);
340
0
  WINPR_UNUSED(s);
341
0
  WINPR_UNUSED(hints);
342
0
  WINPR_UNUSED(res);
343
0
  WLog_ERR(TAG, "TODO: implement this");
344
0
  return FALSE;
345
0
}
346
347
void ndr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel,
348
                                     const KERB_RPC_INTERNAL_NAME* obj)
349
0
{
350
0
  WINPR_UNUSED(indentLevel);
351
0
  WINPR_UNUSED(obj);
352
0
  WLog_Print(logger, lvl, "TODO: implement this");
353
0
}
354
355
static void ndr_descr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel,
356
                                                  const void* obj)
357
0
{
358
0
  ndr_dump_KERB_RPC_INTERNAL_NAME(logger, lvl, indentLevel, obj);
359
0
}
360
361
void ndr_destroy_KERB_RPC_INTERNAL_NAME(NdrContext* context, const void* hints,
362
                                        KERB_RPC_INTERNAL_NAME* obj)
363
0
{
364
0
  WINPR_UNUSED(hints);
365
0
  if (!obj)
366
0
    return;
367
368
0
  if (obj->Names)
369
0
  {
370
0
    for (UINT32 i = 0; i < obj->nameHints.count; i++)
371
0
      ndr_destroy_RPC_UNICODE_STRING(context, nullptr, &obj->Names[i]);
372
0
  }
373
374
0
  free(obj->Names);
375
0
  obj->Names = nullptr;
376
0
  obj->nameHints.count = 0;
377
0
}
378
379
static void ndr_descr_destroy_KERB_RPC_INTERNAL_NAME(NdrContext* context, const void* hints,
380
                                                     void* obj)
381
0
{
382
0
  ndr_destroy_KERB_RPC_INTERNAL_NAME(context, hints, obj);
383
0
}
384
385
static NdrMessageDescr KERB_RPC_INTERNAL_NAME_descr_s = { NDR_ARITY_SIMPLE,
386
                                                        sizeof(KERB_RPC_INTERNAL_NAME),
387
                                                        ndr_descr_read_KERB_RPC_INTERNAL_NAME,
388
                                                        nullptr,
389
                                                        ndr_descr_destroy_KERB_RPC_INTERNAL_NAME,
390
                                                        ndr_descr_dump_KERB_RPC_INTERNAL_NAME };
391
392
NdrMessageType ndr_KERB_RPC_INTERNAL_NAME_descr(void)
393
0
{
394
0
  return &KERB_RPC_INTERNAL_NAME_descr_s;
395
0
}
396
397
/* ========================== KERB_RPC_ENCRYPTION_KEY ======================== */
398
399
static const NdrFieldStruct KERB_RPC_ENCRYPTION_KEY_fields[] = {
400
  { "reserved1", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved1), NDR_NOT_POINTER, -1,
401
    &ndr_uint32_descr_s },
402
  { "reserved2", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved2), NDR_NOT_POINTER, -1,
403
    &ndr_uint32_descr_s },
404
  { "reserved3", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved3), NDR_NOT_POINTER, -1,
405
    &ndr_KERB_RPC_OCTET_STRING_descr_s }
406
};
407
static const NdrStructDescr KERB_RPC_ENCRYPTION_KEY_struct = {
408
  "KERB_RPC_ENCRYPTION_KEY", ARRAYSIZE(KERB_RPC_ENCRYPTION_KEY_fields),
409
  KERB_RPC_ENCRYPTION_KEY_fields
410
};
411
412
RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_ENCRYPTION_KEY)
413
414
/* ========================== BuildEncryptedAuthDataReq ======================== */
415
416
static const NdrFieldStruct BuildEncryptedAuthDataReq_fields[] = {
417
  { "KeyUsage", offsetof(BuildEncryptedAuthDataReq, KeyUsage), NDR_NOT_POINTER, -1,
418
    &ndr_uint32_descr_s },
419
  { "key", offsetof(BuildEncryptedAuthDataReq, Key), NDR_POINTER_NON_NULL, -1,
420
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
421
  { "plainAuthData", offsetof(BuildEncryptedAuthDataReq, PlainAuthData), NDR_POINTER_NON_NULL, -1,
422
    &ndr_KERB_ASN1_DATA_descr_s }
423
};
424
static const NdrStructDescr BuildEncryptedAuthDataReq_struct = {
425
  "BuildEncryptedAuthDataReq", ARRAYSIZE(BuildEncryptedAuthDataReq_fields),
426
  BuildEncryptedAuthDataReq_fields
427
};
428
429
RDPEAR_SIMPLE_MESSAGE_TYPE(BuildEncryptedAuthDataReq)
430
431
/* ========================== ComputeTgsChecksumReq ======================== */
432
433
static const NdrFieldStruct ComputeTgsChecksumReq_fields[] = {
434
  { "requestBody", offsetof(ComputeTgsChecksumReq, requestBody), NDR_POINTER_NON_NULL, -1,
435
    &ndr_KERB_ASN1_DATA_descr_s },
436
  { "key", offsetof(ComputeTgsChecksumReq, Key), NDR_POINTER_NON_NULL, -1,
437
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
438
  { "ChecksumType", offsetof(ComputeTgsChecksumReq, ChecksumType), NDR_NOT_POINTER, -1,
439
    &ndr_uint32_descr_s }
440
};
441
static const NdrStructDescr ComputeTgsChecksumReq_struct = {
442
  "ComputeTgsChecksumReq", ARRAYSIZE(ComputeTgsChecksumReq_fields), ComputeTgsChecksumReq_fields
443
};
444
445
RDPEAR_SIMPLE_MESSAGE_TYPE(ComputeTgsChecksumReq)
446
447
/* ========================== CreateApReqAuthenticatorReq ======================== */
448
449
static const NdrFieldStruct CreateApReqAuthenticatorReq_fields[] = {
450
  { "EncryptionKey", offsetof(CreateApReqAuthenticatorReq, EncryptionKey), NDR_POINTER_NON_NULL,
451
    -1, &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
452
  { "SequenceNumber", offsetof(CreateApReqAuthenticatorReq, SequenceNumber), NDR_NOT_POINTER, -1,
453
    &ndr_uint32_descr_s },
454
  { "ClientName", offsetof(CreateApReqAuthenticatorReq, ClientName), NDR_POINTER_NON_NULL, -1,
455
    &KERB_RPC_INTERNAL_NAME_descr_s },
456
  { "ClientRealm", offsetof(CreateApReqAuthenticatorReq, ClientRealm), NDR_POINTER_NON_NULL, -1,
457
    &RPC_UNICODE_STRING_descr_s },
458
  { "SkewTime", offsetof(CreateApReqAuthenticatorReq, SkewTime), NDR_POINTER_NON_NULL, -1,
459
    &ndr_uint64_descr_s },
460
  { "SubKey", offsetof(CreateApReqAuthenticatorReq, SubKey), NDR_POINTER, -1,
461
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
462
  { "AuthData", offsetof(CreateApReqAuthenticatorReq, AuthData), NDR_POINTER_NON_NULL, -1,
463
    &ndr_KERB_ASN1_DATA_descr_s },
464
  { "GssChecksum", offsetof(CreateApReqAuthenticatorReq, GssChecksum), NDR_POINTER, -1,
465
    &ndr_KERB_ASN1_DATA_descr_s },
466
  { "KeyUsage", offsetof(CreateApReqAuthenticatorReq, KeyUsage), NDR_NOT_POINTER, -1,
467
    &ndr_uint32_descr_s },
468
};
469
static const NdrStructDescr CreateApReqAuthenticatorReq_struct = {
470
  "CreateApReqAuthenticatorReq", ARRAYSIZE(CreateApReqAuthenticatorReq_fields),
471
  CreateApReqAuthenticatorReq_fields
472
};
473
474
RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorReq)
475
476
/* ========================== CreateApReqAuthenticatorResp ======================== */
477
478
static const NdrFieldStruct CreateApReqAuthenticatorResp_fields[] = {
479
  { "AuthenticatorTime", offsetof(CreateApReqAuthenticatorResp, AuthenticatorTime),
480
    NDR_NOT_POINTER, -1, &ndr_uint64_descr_s },
481
  { "Authenticator", offsetof(CreateApReqAuthenticatorResp, Authenticator), NDR_NOT_POINTER, -1,
482
    &ndr_KERB_ASN1_DATA_descr_s },
483
  { "KerbProtocolError", offsetof(CreateApReqAuthenticatorResp, KerbProtocolError),
484
    NDR_NOT_POINTER, -1, &ndr_uint32_descr_s },
485
};
486
487
static const NdrStructDescr CreateApReqAuthenticatorResp_struct = {
488
  "CreateApReqAuthenticatorResp", ARRAYSIZE(CreateApReqAuthenticatorResp_fields),
489
  CreateApReqAuthenticatorResp_fields
490
};
491
492
RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorResp)
493
494
/* ========================== UnpackKdcReplyBodyReq ======================== */
495
496
static const NdrFieldStruct UnpackKdcReplyBodyReq_fields[] = {
497
  { "EncryptedData", offsetof(UnpackKdcReplyBodyReq, EncryptedData), NDR_POINTER_NON_NULL, -1,
498
    &ndr_KERB_ASN1_DATA_descr_s },
499
  { "Key", offsetof(UnpackKdcReplyBodyReq, Key), NDR_POINTER_NON_NULL, -1,
500
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
501
  { "StrenghtenKey", offsetof(UnpackKdcReplyBodyReq, StrengthenKey), NDR_POINTER, -1,
502
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s },
503
  { "Pdu", offsetof(UnpackKdcReplyBodyReq, Pdu), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s },
504
  { "KeyUsage", offsetof(UnpackKdcReplyBodyReq, KeyUsage), NDR_NOT_POINTER, -1,
505
    &ndr_uint32_descr_s },
506
};
507
508
static const NdrStructDescr UnpackKdcReplyBodyReq_struct = {
509
  "UnpackKdcReplyBodyReq", ARRAYSIZE(UnpackKdcReplyBodyReq_fields), UnpackKdcReplyBodyReq_fields
510
};
511
512
RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyReq)
513
514
/* ========================== UnpackKdcReplyBodyResp ======================== */
515
516
static const NdrFieldStruct UnpackKdcReplyBodyResp_fields[] = {
517
  { "KerbProtocolError", offsetof(UnpackKdcReplyBodyResp, KerbProtocolError), NDR_NOT_POINTER, -1,
518
    &ndr_uint32_descr_s },
519
  { "ReplyBody", offsetof(UnpackKdcReplyBodyResp, ReplyBody), NDR_NOT_POINTER, -1,
520
    &ndr_KERB_ASN1_DATA_descr_s }
521
};
522
523
static const NdrStructDescr UnpackKdcReplyBodyResp_struct = {
524
  "UnpackKdcReplyBodyResp", ARRAYSIZE(UnpackKdcReplyBodyResp_fields),
525
  UnpackKdcReplyBodyResp_fields
526
};
527
528
RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyResp)
529
530
/* ========================== DecryptApReplyReq ======================== */
531
532
static const NdrFieldStruct DecryptApReplyReq_fields[] = {
533
  { "EncryptedReply", offsetof(DecryptApReplyReq, EncryptedReply), NDR_POINTER_NON_NULL, -1,
534
    &ndr_KERB_ASN1_DATA_descr_s },
535
  { "Key", offsetof(DecryptApReplyReq, Key), NDR_POINTER_NON_NULL, -1,
536
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }
537
};
538
539
static const NdrStructDescr DecryptApReplyReq_struct = { "DecryptApReplyReq",
540
                                                       ARRAYSIZE(DecryptApReplyReq_fields),
541
                                                       DecryptApReplyReq_fields };
542
543
RDPEAR_SIMPLE_MESSAGE_TYPE(DecryptApReplyReq)
544
545
/* ========================== PackApReplyReq ======================== */
546
547
static const NdrFieldStruct PackApReplyReq_fields[] = {
548
  { "Reply", offsetof(PackApReplyReq, Reply), NDR_POINTER_NON_NULL, -1,
549
    &ndr_KERB_ASN1_DATA_descr_s },
550
  { "ReplyBody", offsetof(PackApReplyReq, ReplyBody), NDR_POINTER_NON_NULL, -1,
551
    &ndr_KERB_ASN1_DATA_descr_s },
552
  { "SessionKey", offsetof(PackApReplyReq, SessionKey), NDR_POINTER_NON_NULL, -1,
553
    &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }
554
};
555
556
static const NdrStructDescr PackApReplyReq_struct = { "PackApReplyReq",
557
                                                    ARRAYSIZE(PackApReplyReq_fields),
558
                                                    PackApReplyReq_fields };
559
560
RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyReq)
561
562
/* ========================== PackApReplyResp ======================== */
563
564
static const NdrFieldStruct PackApReplyResp_fields[] = {
565
  { "PackedReplySize", offsetof(PackApReplyResp, PackedReplyHints), NDR_NOT_POINTER, -1,
566
    &ndr_uint32_descr_s },
567
  { "PackedReply", offsetof(PackApReplyResp, PackedReply), NDR_POINTER_NON_NULL, 0,
568
    &ndr_uint8Array_descr_s },
569
};
570
571
static const NdrStructDescr PackApReplyResp_struct = { "PackApReplyResp",
572
                                                     ARRAYSIZE(PackApReplyResp_fields),
573
                                                     PackApReplyResp_fields };
574
575
RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyResp)