/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 = NULL; |
50 | 0 | WinPrAsn1Encoder* enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER); |
51 | 0 | if (!enc) |
52 | 0 | return NULL; |
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(NULL, 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 = NULL; |
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 = NULL; |
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 | | NULL, |
296 | | NULL |
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 | |
|
320 | 0 | UINT16 nameCount = 0; |
321 | 0 | WINPR_UNUSED(hints); |
322 | |
|
323 | 0 | if (!ndr_read_uint16(context, s, &res->NameType) || !ndr_read_uint16(context, s, &nameCount)) |
324 | 0 | return FALSE; |
325 | | |
326 | 0 | res->nameHints.count = nameCount; |
327 | |
|
328 | 0 | return ndr_read_refpointer(context, s, &names.ptrId) && ndr_push_deferreds(context, &names, 1); |
329 | 0 | } |
330 | | |
331 | | static BOOL ndr_descr_read_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, |
332 | | const void* hints, void* res) |
333 | 0 | { |
334 | 0 | return ndr_read_KERB_RPC_INTERNAL_NAME(context, s, hints, res); |
335 | 0 | } |
336 | | |
337 | | BOOL ndr_write_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, const void* hints, |
338 | | const KERB_RPC_INTERNAL_NAME* res) |
339 | 0 | { |
340 | 0 | WINPR_UNUSED(context); |
341 | 0 | WINPR_UNUSED(s); |
342 | 0 | WINPR_UNUSED(hints); |
343 | 0 | WINPR_UNUSED(res); |
344 | 0 | WLog_ERR(TAG, "TODO: implement this"); |
345 | 0 | return FALSE; |
346 | 0 | } |
347 | | |
348 | | void ndr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel, |
349 | | const KERB_RPC_INTERNAL_NAME* obj) |
350 | 0 | { |
351 | 0 | WINPR_UNUSED(indentLevel); |
352 | 0 | WINPR_UNUSED(obj); |
353 | 0 | WLog_Print(logger, lvl, "TODO: implement this"); |
354 | 0 | } |
355 | | |
356 | | static void ndr_descr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel, |
357 | | const void* obj) |
358 | 0 | { |
359 | 0 | ndr_dump_KERB_RPC_INTERNAL_NAME(logger, lvl, indentLevel, obj); |
360 | 0 | } |
361 | | |
362 | | void ndr_destroy_KERB_RPC_INTERNAL_NAME(NdrContext* context, const void* hints, |
363 | | KERB_RPC_INTERNAL_NAME* obj) |
364 | 0 | { |
365 | 0 | WINPR_UNUSED(hints); |
366 | 0 | if (!obj) |
367 | 0 | return; |
368 | | |
369 | 0 | for (UINT32 i = 0; i < obj->nameHints.count; i++) |
370 | 0 | ndr_destroy_RPC_UNICODE_STRING(context, NULL, &obj->Names[i]); |
371 | |
|
372 | 0 | free(obj->Names); |
373 | 0 | obj->Names = NULL; |
374 | 0 | } |
375 | | |
376 | | static void ndr_descr_destroy_KERB_RPC_INTERNAL_NAME(NdrContext* context, const void* hints, |
377 | | void* obj) |
378 | 0 | { |
379 | 0 | ndr_destroy_KERB_RPC_INTERNAL_NAME(context, hints, obj); |
380 | 0 | } |
381 | | |
382 | | static NdrMessageDescr KERB_RPC_INTERNAL_NAME_descr_s = { NDR_ARITY_SIMPLE, |
383 | | sizeof(KERB_RPC_INTERNAL_NAME), |
384 | | ndr_descr_read_KERB_RPC_INTERNAL_NAME, |
385 | | NULL, |
386 | | ndr_descr_destroy_KERB_RPC_INTERNAL_NAME, |
387 | | ndr_descr_dump_KERB_RPC_INTERNAL_NAME }; |
388 | | |
389 | | NdrMessageType ndr_KERB_RPC_INTERNAL_NAME_descr(void) |
390 | 0 | { |
391 | 0 | return &KERB_RPC_INTERNAL_NAME_descr_s; |
392 | 0 | } |
393 | | |
394 | | /* ========================== KERB_RPC_ENCRYPTION_KEY ======================== */ |
395 | | |
396 | | static const NdrFieldStruct KERB_RPC_ENCRYPTION_KEY_fields[] = { |
397 | | { "reserved1", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved1), NDR_NOT_POINTER, -1, |
398 | | &ndr_uint32_descr_s }, |
399 | | { "reserved2", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved2), NDR_NOT_POINTER, -1, |
400 | | &ndr_uint32_descr_s }, |
401 | | { "reserved3", offsetof(KERB_RPC_ENCRYPTION_KEY, reserved3), NDR_NOT_POINTER, -1, |
402 | | &ndr_KERB_RPC_OCTET_STRING_descr_s } |
403 | | }; |
404 | | static const NdrStructDescr KERB_RPC_ENCRYPTION_KEY_struct = { |
405 | | "KERB_RPC_ENCRYPTION_KEY", ARRAYSIZE(KERB_RPC_ENCRYPTION_KEY_fields), |
406 | | KERB_RPC_ENCRYPTION_KEY_fields |
407 | | }; |
408 | | |
409 | | RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_ENCRYPTION_KEY) |
410 | | |
411 | | /* ========================== BuildEncryptedAuthDataReq ======================== */ |
412 | | |
413 | | static const NdrFieldStruct BuildEncryptedAuthDataReq_fields[] = { |
414 | | { "KeyUsage", offsetof(BuildEncryptedAuthDataReq, KeyUsage), NDR_NOT_POINTER, -1, |
415 | | &ndr_uint32_descr_s }, |
416 | | { "key", offsetof(BuildEncryptedAuthDataReq, Key), NDR_POINTER_NON_NULL, -1, |
417 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
418 | | { "plainAuthData", offsetof(BuildEncryptedAuthDataReq, PlainAuthData), NDR_POINTER_NON_NULL, -1, |
419 | | &ndr_KERB_ASN1_DATA_descr_s } |
420 | | }; |
421 | | static const NdrStructDescr BuildEncryptedAuthDataReq_struct = { |
422 | | "BuildEncryptedAuthDataReq", ARRAYSIZE(BuildEncryptedAuthDataReq_fields), |
423 | | BuildEncryptedAuthDataReq_fields |
424 | | }; |
425 | | |
426 | | RDPEAR_SIMPLE_MESSAGE_TYPE(BuildEncryptedAuthDataReq) |
427 | | |
428 | | /* ========================== ComputeTgsChecksumReq ======================== */ |
429 | | |
430 | | static const NdrFieldStruct ComputeTgsChecksumReq_fields[] = { |
431 | | { "requestBody", offsetof(ComputeTgsChecksumReq, requestBody), NDR_POINTER_NON_NULL, -1, |
432 | | &ndr_KERB_ASN1_DATA_descr_s }, |
433 | | { "key", offsetof(ComputeTgsChecksumReq, Key), NDR_POINTER_NON_NULL, -1, |
434 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
435 | | { "ChecksumType", offsetof(ComputeTgsChecksumReq, ChecksumType), NDR_NOT_POINTER, -1, |
436 | | &ndr_uint32_descr_s } |
437 | | }; |
438 | | static const NdrStructDescr ComputeTgsChecksumReq_struct = { |
439 | | "ComputeTgsChecksumReq", ARRAYSIZE(ComputeTgsChecksumReq_fields), ComputeTgsChecksumReq_fields |
440 | | }; |
441 | | |
442 | | RDPEAR_SIMPLE_MESSAGE_TYPE(ComputeTgsChecksumReq) |
443 | | |
444 | | /* ========================== CreateApReqAuthenticatorReq ======================== */ |
445 | | |
446 | | static const NdrFieldStruct CreateApReqAuthenticatorReq_fields[] = { |
447 | | { "EncryptionKey", offsetof(CreateApReqAuthenticatorReq, EncryptionKey), NDR_POINTER_NON_NULL, |
448 | | -1, &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
449 | | { "SequenceNumber", offsetof(CreateApReqAuthenticatorReq, SequenceNumber), NDR_NOT_POINTER, -1, |
450 | | &ndr_uint32_descr_s }, |
451 | | { "ClientName", offsetof(CreateApReqAuthenticatorReq, ClientName), NDR_POINTER_NON_NULL, -1, |
452 | | &KERB_RPC_INTERNAL_NAME_descr_s }, |
453 | | { "ClientRealm", offsetof(CreateApReqAuthenticatorReq, ClientRealm), NDR_POINTER_NON_NULL, -1, |
454 | | &RPC_UNICODE_STRING_descr_s }, |
455 | | { "SkewTime", offsetof(CreateApReqAuthenticatorReq, SkewTime), NDR_POINTER_NON_NULL, -1, |
456 | | &ndr_uint64_descr_s }, |
457 | | { "SubKey", offsetof(CreateApReqAuthenticatorReq, SubKey), NDR_POINTER, -1, |
458 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
459 | | { "AuthData", offsetof(CreateApReqAuthenticatorReq, AuthData), NDR_POINTER_NON_NULL, -1, |
460 | | &ndr_KERB_ASN1_DATA_descr_s }, |
461 | | { "GssChecksum", offsetof(CreateApReqAuthenticatorReq, GssChecksum), NDR_POINTER, -1, |
462 | | &ndr_KERB_ASN1_DATA_descr_s }, |
463 | | { "KeyUsage", offsetof(CreateApReqAuthenticatorReq, KeyUsage), NDR_NOT_POINTER, -1, |
464 | | &ndr_uint32_descr_s }, |
465 | | }; |
466 | | static const NdrStructDescr CreateApReqAuthenticatorReq_struct = { |
467 | | "CreateApReqAuthenticatorReq", ARRAYSIZE(CreateApReqAuthenticatorReq_fields), |
468 | | CreateApReqAuthenticatorReq_fields |
469 | | }; |
470 | | |
471 | | RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorReq) |
472 | | |
473 | | /* ========================== CreateApReqAuthenticatorResp ======================== */ |
474 | | |
475 | | static const NdrFieldStruct CreateApReqAuthenticatorResp_fields[] = { |
476 | | { "AuthenticatorTime", offsetof(CreateApReqAuthenticatorResp, AuthenticatorTime), |
477 | | NDR_NOT_POINTER, -1, &ndr_uint64_descr_s }, |
478 | | { "Authenticator", offsetof(CreateApReqAuthenticatorResp, Authenticator), NDR_NOT_POINTER, -1, |
479 | | &ndr_KERB_ASN1_DATA_descr_s }, |
480 | | { "KerbProtocolError", offsetof(CreateApReqAuthenticatorResp, KerbProtocolError), |
481 | | NDR_NOT_POINTER, -1, &ndr_uint32_descr_s }, |
482 | | }; |
483 | | |
484 | | static const NdrStructDescr CreateApReqAuthenticatorResp_struct = { |
485 | | "CreateApReqAuthenticatorResp", ARRAYSIZE(CreateApReqAuthenticatorResp_fields), |
486 | | CreateApReqAuthenticatorResp_fields |
487 | | }; |
488 | | |
489 | | RDPEAR_SIMPLE_MESSAGE_TYPE(CreateApReqAuthenticatorResp) |
490 | | |
491 | | /* ========================== UnpackKdcReplyBodyReq ======================== */ |
492 | | |
493 | | static const NdrFieldStruct UnpackKdcReplyBodyReq_fields[] = { |
494 | | { "EncryptedData", offsetof(UnpackKdcReplyBodyReq, EncryptedData), NDR_POINTER_NON_NULL, -1, |
495 | | &ndr_KERB_ASN1_DATA_descr_s }, |
496 | | { "Key", offsetof(UnpackKdcReplyBodyReq, Key), NDR_POINTER_NON_NULL, -1, |
497 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
498 | | { "StrenghtenKey", offsetof(UnpackKdcReplyBodyReq, StrengthenKey), NDR_POINTER, -1, |
499 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s }, |
500 | | { "Pdu", offsetof(UnpackKdcReplyBodyReq, Pdu), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s }, |
501 | | { "KeyUsage", offsetof(UnpackKdcReplyBodyReq, KeyUsage), NDR_NOT_POINTER, -1, |
502 | | &ndr_uint32_descr_s }, |
503 | | }; |
504 | | |
505 | | static const NdrStructDescr UnpackKdcReplyBodyReq_struct = { |
506 | | "UnpackKdcReplyBodyReq", ARRAYSIZE(UnpackKdcReplyBodyReq_fields), UnpackKdcReplyBodyReq_fields |
507 | | }; |
508 | | |
509 | | RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyReq) |
510 | | |
511 | | /* ========================== UnpackKdcReplyBodyResp ======================== */ |
512 | | |
513 | | static const NdrFieldStruct UnpackKdcReplyBodyResp_fields[] = { |
514 | | { "KerbProtocolError", offsetof(UnpackKdcReplyBodyResp, KerbProtocolError), NDR_NOT_POINTER, -1, |
515 | | &ndr_uint32_descr_s }, |
516 | | { "ReplyBody", offsetof(UnpackKdcReplyBodyResp, ReplyBody), NDR_NOT_POINTER, -1, |
517 | | &ndr_KERB_ASN1_DATA_descr_s } |
518 | | }; |
519 | | |
520 | | static const NdrStructDescr UnpackKdcReplyBodyResp_struct = { |
521 | | "UnpackKdcReplyBodyResp", ARRAYSIZE(UnpackKdcReplyBodyResp_fields), |
522 | | UnpackKdcReplyBodyResp_fields |
523 | | }; |
524 | | |
525 | | RDPEAR_SIMPLE_MESSAGE_TYPE(UnpackKdcReplyBodyResp) |
526 | | |
527 | | /* ========================== DecryptApReplyReq ======================== */ |
528 | | |
529 | | static const NdrFieldStruct DecryptApReplyReq_fields[] = { |
530 | | { "EncryptedReply", offsetof(DecryptApReplyReq, EncryptedReply), NDR_POINTER_NON_NULL, -1, |
531 | | &ndr_KERB_ASN1_DATA_descr_s }, |
532 | | { "Key", offsetof(DecryptApReplyReq, Key), NDR_POINTER_NON_NULL, -1, |
533 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s } |
534 | | }; |
535 | | |
536 | | static const NdrStructDescr DecryptApReplyReq_struct = { "DecryptApReplyReq", |
537 | | ARRAYSIZE(DecryptApReplyReq_fields), |
538 | | DecryptApReplyReq_fields }; |
539 | | |
540 | | RDPEAR_SIMPLE_MESSAGE_TYPE(DecryptApReplyReq) |
541 | | |
542 | | /* ========================== PackApReplyReq ======================== */ |
543 | | |
544 | | static const NdrFieldStruct PackApReplyReq_fields[] = { |
545 | | { "Reply", offsetof(PackApReplyReq, Reply), NDR_POINTER_NON_NULL, -1, |
546 | | &ndr_KERB_ASN1_DATA_descr_s }, |
547 | | { "ReplyBody", offsetof(PackApReplyReq, ReplyBody), NDR_POINTER_NON_NULL, -1, |
548 | | &ndr_KERB_ASN1_DATA_descr_s }, |
549 | | { "SessionKey", offsetof(PackApReplyReq, SessionKey), NDR_POINTER_NON_NULL, -1, |
550 | | &ndr_KERB_RPC_ENCRYPTION_KEY_descr_s } |
551 | | }; |
552 | | |
553 | | static const NdrStructDescr PackApReplyReq_struct = { "PackApReplyReq", |
554 | | ARRAYSIZE(PackApReplyReq_fields), |
555 | | PackApReplyReq_fields }; |
556 | | |
557 | | RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyReq) |
558 | | |
559 | | /* ========================== PackApReplyResp ======================== */ |
560 | | |
561 | | static const NdrFieldStruct PackApReplyResp_fields[] = { |
562 | | { "PackedReplySize", offsetof(PackApReplyResp, PackedReplyHints), NDR_NOT_POINTER, -1, |
563 | | &ndr_uint32_descr_s }, |
564 | | { "PackedReply", offsetof(PackApReplyResp, PackedReply), NDR_POINTER_NON_NULL, 0, |
565 | | &ndr_uint8Array_descr_s }, |
566 | | }; |
567 | | |
568 | | static const NdrStructDescr PackApReplyResp_struct = { "PackApReplyResp", |
569 | | ARRAYSIZE(PackApReplyResp_fields), |
570 | | PackApReplyResp_fields }; |
571 | | |
572 | | RDPEAR_SIMPLE_MESSAGE_TYPE(PackApReplyResp) |