/src/FreeRDP/channels/rdpear/common/rdpear_common.c
Line | Count | Source (jump to first uncovered line) |
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(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(RdpEarPackageType packageType, 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 | switch (packageType) |
61 | 0 | { |
62 | 0 | case RDPEAR_PACKAGE_KERBEROS: |
63 | 0 | packageOctetString.data = (BYTE*)kerberosPackageName; |
64 | 0 | packageOctetString.len = sizeof(kerberosPackageName); |
65 | 0 | break; |
66 | 0 | case RDPEAR_PACKAGE_NTLM: |
67 | 0 | packageOctetString.data = (BYTE*)ntlmPackageName; |
68 | 0 | packageOctetString.len = sizeof(ntlmPackageName); |
69 | 0 | break; |
70 | 0 | default: |
71 | 0 | goto out; |
72 | 0 | } |
73 | | |
74 | 0 | if (!WinPrAsn1EncContextualOctetString(enc, 1, &packageOctetString)) |
75 | 0 | goto out; |
76 | | |
77 | | /* buffer [2] OCTET STRING*/ |
78 | 0 | WinPrAsn1_OctetString payloadOctetString = { Stream_GetPosition(payload), |
79 | 0 | Stream_Buffer(payload) }; |
80 | 0 | if (!WinPrAsn1EncContextualOctetString(enc, 2, &payloadOctetString)) |
81 | 0 | goto out; |
82 | | |
83 | | /* } */ |
84 | 0 | if (!WinPrAsn1EncEndContainer(enc)) |
85 | 0 | goto out; |
86 | | |
87 | 0 | ret = Stream_New(NULL, 100); |
88 | 0 | if (!ret) |
89 | 0 | goto out; |
90 | | |
91 | 0 | if (!WinPrAsn1EncToStream(enc, ret)) |
92 | 0 | { |
93 | 0 | Stream_Free(ret, TRUE); |
94 | 0 | ret = NULL; |
95 | 0 | goto out; |
96 | 0 | } |
97 | 0 | out: |
98 | 0 | WinPrAsn1Encoder_Free(&enc); |
99 | 0 | return ret; |
100 | 0 | } |
101 | | |
102 | | #define RDPEAR_SIMPLE_MESSAGE_TYPE(V) \ |
103 | | BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj) \ |
104 | 0 | { \ |
105 | 0 | WINPR_UNUSED(hints); \ |
106 | 0 | return ndr_struct_read_fromDescr(context, s, &V##_struct, obj); \ |
107 | 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 |
108 | | BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, const V* obj) \ |
109 | 0 | { \ |
110 | 0 | WINPR_UNUSED(hints); \ |
111 | 0 | return ndr_struct_write_fromDescr(context, s, &V##_struct, obj); \ |
112 | 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 |
113 | | void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj) \ |
114 | 0 | { \ |
115 | 0 | WINPR_UNUSED(hints); \ |
116 | 0 | ndr_struct_destroy(context, &V##_struct, obj); \ |
117 | 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 |
118 | | void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj) \ |
119 | 0 | { \ |
120 | 0 | ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj); \ |
121 | 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 |
122 | | \ |
123 | | static BOOL ndr_descr_read_##V(NdrContext* context, wStream* s, const void* hints, void* obj) \ |
124 | 0 | { \ |
125 | 0 | WINPR_UNUSED(hints); \ |
126 | 0 | return ndr_struct_read_fromDescr(context, s, &V##_struct, obj); \ |
127 | 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 |
128 | | static BOOL ndr_descr_write_##V(NdrContext* context, wStream* s, const void* hints, \ |
129 | | const void* obj) \ |
130 | 0 | { \ |
131 | 0 | WINPR_UNUSED(hints); \ |
132 | 0 | return ndr_struct_write_fromDescr(context, s, &V##_struct, obj); \ |
133 | 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 |
134 | | static void ndr_descr_destroy_##V(NdrContext* context, const void* hints, void* obj) \ |
135 | 0 | { \ |
136 | 0 | WINPR_UNUSED(hints); \ |
137 | 0 | ndr_struct_destroy(context, &V##_struct, obj); \ |
138 | 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 |
139 | | static void ndr_descr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const void* obj) \ |
140 | 0 | { \ |
141 | 0 | ndr_struct_dump_fromDescr(logger, lvl, indentLevel, &V##_struct, obj); \ |
142 | 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 |
143 | | \ |
144 | | static NdrMessageDescr ndr_##V##_descr_s = { \ |
145 | | NDR_ARITY_SIMPLE, sizeof(V), ndr_descr_read_##V, ndr_descr_write_##V, \ |
146 | | ndr_descr_destroy_##V, ndr_descr_dump_##V, \ |
147 | | }; \ |
148 | | \ |
149 | | NdrMessageType ndr_##V##_descr(void) \ |
150 | 0 | { \ |
151 | 0 | return &ndr_##V##_descr_s; \ |
152 | 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 |
153 | | |
154 | | static const NdrFieldStruct KERB_RPC_OCTET_STRING_fields[] = { |
155 | | { "Length", offsetof(KERB_RPC_OCTET_STRING, length), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s }, |
156 | | { "value", offsetof(KERB_RPC_OCTET_STRING, value), NDR_POINTER_NON_NULL, 0, |
157 | | &ndr_uint8Array_descr_s } |
158 | | }; |
159 | | static const NdrStructDescr KERB_RPC_OCTET_STRING_struct = { "KERB_RPC_OCTET_STRING", 2, |
160 | | KERB_RPC_OCTET_STRING_fields }; |
161 | | |
162 | | RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_RPC_OCTET_STRING) |
163 | | |
164 | | /* ============================= KERB_ASN1_DATA ============================== */ |
165 | | |
166 | | static const NdrFieldStruct KERB_ASN1_DATA_fields[] = { |
167 | | { "Pdu", offsetof(KERB_ASN1_DATA, Pdu), NDR_NOT_POINTER, -1, &ndr_uint32_descr_s }, |
168 | | { "Count", offsetof(KERB_ASN1_DATA, Asn1BufferHints.count), NDR_NOT_POINTER, -1, |
169 | | &ndr_uint32_descr_s }, |
170 | | { "Asn1Buffer", offsetof(KERB_ASN1_DATA, Asn1Buffer), NDR_POINTER_NON_NULL, 1, |
171 | | &ndr_uint8Array_descr_s } |
172 | | }; |
173 | | static const NdrStructDescr KERB_ASN1_DATA_struct = { "KERB_ASN1_DATA", |
174 | | ARRAYSIZE(KERB_ASN1_DATA_fields), |
175 | | KERB_ASN1_DATA_fields }; |
176 | | |
177 | | RDPEAR_SIMPLE_MESSAGE_TYPE(KERB_ASN1_DATA) |
178 | | |
179 | | /* ============================ RPC_UNICODE_STRING ========================== */ |
180 | | |
181 | | BOOL ndr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints, |
182 | | RPC_UNICODE_STRING* res) |
183 | 0 | { |
184 | 0 | NdrDeferredEntry bufferDesc = { NDR_PTR_NULL, "RPC_UNICODE_STRING.Buffer", &res->lenHints, |
185 | 0 | (void*)&res->Buffer, ndr_uint16VaryingArray_descr() }; |
186 | 0 | UINT16 Length = 0; |
187 | 0 | UINT16 MaximumLength = 0; |
188 | |
|
189 | 0 | WINPR_UNUSED(hints); |
190 | 0 | if (!ndr_read_uint16(context, s, &Length) || !ndr_read_uint16(context, s, &MaximumLength) || |
191 | 0 | !ndr_read_refpointer(context, s, &bufferDesc.ptrId) || Length > MaximumLength) |
192 | 0 | return FALSE; |
193 | | |
194 | 0 | res->lenHints.length = Length; |
195 | 0 | res->lenHints.maxLength = MaximumLength; |
196 | 0 | res->strLength = Length / 2; |
197 | |
|
198 | 0 | return ndr_push_deferreds(context, &bufferDesc, 1); |
199 | 0 | } |
200 | | |
201 | | static BOOL ndr_descr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints, |
202 | | void* res) |
203 | 0 | { |
204 | 0 | return ndr_read_RPC_UNICODE_STRING(context, s, hints, res); |
205 | 0 | } |
206 | | |
207 | | BOOL ndr_write_RPC_UNICODE_STRING(NdrContext* context, wStream* s, |
208 | | WINPR_ATTR_UNUSED const void* hints, |
209 | | const RPC_UNICODE_STRING* res) |
210 | 0 | { |
211 | 0 | WINPR_ASSERT(res); |
212 | 0 | if (!ndr_write_uint32(context, s, res->lenHints.length)) |
213 | 0 | return FALSE; |
214 | | |
215 | 0 | if (!ndr_write_uint32(context, s, res->lenHints.maxLength)) |
216 | 0 | return FALSE; |
217 | | |
218 | 0 | return ndr_write_data(context, s, res->Buffer, res->strLength); |
219 | 0 | } |
220 | | |
221 | | static BOOL ndr_write_RPC_UNICODE_STRING_(NdrContext* context, wStream* s, const void* hints, |
222 | | const void* pvres) |
223 | 0 | { |
224 | 0 | const RPC_UNICODE_STRING* res = pvres; |
225 | 0 | return ndr_write_RPC_UNICODE_STRING(context, s, hints, res); |
226 | 0 | } |
227 | | |
228 | | void ndr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel, |
229 | | const RPC_UNICODE_STRING* obj) |
230 | 0 | { |
231 | 0 | WINPR_UNUSED(indentLevel); |
232 | 0 | WLog_Print(logger, lvl, "\tLength=%d MaximumLength=%d", obj->lenHints.length, |
233 | 0 | obj->lenHints.maxLength); |
234 | 0 | winpr_HexLogDump(logger, lvl, obj->Buffer, obj->lenHints.length); |
235 | 0 | } |
236 | | |
237 | | static void ndr_descr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel, |
238 | | const void* obj) |
239 | 0 | { |
240 | 0 | ndr_dump_RPC_UNICODE_STRING(logger, lvl, indentLevel, obj); |
241 | 0 | } |
242 | | |
243 | | void ndr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void* hints, RPC_UNICODE_STRING* obj) |
244 | 0 | { |
245 | 0 | WINPR_UNUSED(context); |
246 | 0 | WINPR_UNUSED(hints); |
247 | 0 | if (!obj) |
248 | 0 | return; |
249 | 0 | free(obj->Buffer); |
250 | 0 | obj->Buffer = NULL; |
251 | 0 | } |
252 | | |
253 | | static void ndr_descr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void* hints, void* obj) |
254 | 0 | { |
255 | 0 | ndr_destroy_RPC_UNICODE_STRING(context, hints, obj); |
256 | 0 | } |
257 | | |
258 | | static const NdrMessageDescr RPC_UNICODE_STRING_descr_s = { NDR_ARITY_SIMPLE, |
259 | | sizeof(RPC_UNICODE_STRING), |
260 | | ndr_descr_read_RPC_UNICODE_STRING, |
261 | | ndr_write_RPC_UNICODE_STRING_, |
262 | | ndr_descr_destroy_RPC_UNICODE_STRING, |
263 | | ndr_descr_dump_RPC_UNICODE_STRING }; |
264 | | |
265 | | NdrMessageType ndr_RPC_UNICODE_STRING_descr(void) |
266 | 0 | { |
267 | 0 | return &RPC_UNICODE_STRING_descr_s; |
268 | 0 | } |
269 | | |
270 | | /* ========================= RPC_UNICODE_STRING_Array ======================== */ |
271 | | |
272 | | static BOOL ndr_read_RPC_UNICODE_STRING_Array(NdrContext* context, wStream* s, const void* hints, |
273 | | void* v) |
274 | 0 | { |
275 | 0 | WINPR_ASSERT(context); |
276 | 0 | WINPR_ASSERT(s); |
277 | 0 | WINPR_ASSERT(hints); |
278 | 0 | return ndr_read_uconformant_array(context, s, hints, ndr_RPC_UNICODE_STRING_descr(), v); |
279 | 0 | } |
280 | | |
281 | | static BOOL ndr_write_RPC_UNICODE_STRING_Array(NdrContext* context, wStream* s, const void* ghints, |
282 | | const void* v) |
283 | 0 | { |
284 | 0 | WINPR_ASSERT(context); |
285 | 0 | WINPR_ASSERT(s); |
286 | 0 | WINPR_ASSERT(ghints); |
287 | | |
288 | 0 | const NdrArrayHints* hints = (const NdrArrayHints*)ghints; |
289 | |
|
290 | 0 | return ndr_write_uconformant_array(context, s, hints->count, ndr_RPC_UNICODE_STRING_descr(), v); |
291 | 0 | } |
292 | | |
293 | | static const NdrMessageDescr RPC_UNICODE_STRING_Array_descr_s = { |
294 | | NDR_ARITY_ARRAYOF, |
295 | | sizeof(RPC_UNICODE_STRING), |
296 | | ndr_read_RPC_UNICODE_STRING_Array, |
297 | | ndr_write_RPC_UNICODE_STRING_Array, |
298 | | NULL, |
299 | | NULL |
300 | | }; |
301 | | |
302 | | static NdrMessageType ndr_RPC_UNICODE_STRING_Array_descr(void) |
303 | 0 | { |
304 | 0 | return &RPC_UNICODE_STRING_Array_descr_s; |
305 | 0 | } |
306 | | |
307 | | /* ========================== KERB_RPC_INTERNAL_NAME ======================== */ |
308 | | |
309 | | BOOL ndr_read_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, const void* hints, |
310 | | KERB_RPC_INTERNAL_NAME* res) |
311 | 0 | { |
312 | 0 | WINPR_ASSERT(res); |
313 | | |
314 | 0 | union |
315 | 0 | { |
316 | 0 | RPC_UNICODE_STRING** ppstr; |
317 | 0 | void* pv; |
318 | 0 | } cnv; |
319 | 0 | cnv.ppstr = &res->Names; |
320 | 0 | NdrDeferredEntry names = { NDR_PTR_NULL, "KERB_RPC_INTERNAL_NAME.Names", &res->nameHints, |
321 | 0 | cnv.pv, ndr_RPC_UNICODE_STRING_Array_descr() }; |
322 | |
|
323 | 0 | UINT16 nameCount = 0; |
324 | 0 | WINPR_UNUSED(hints); |
325 | |
|
326 | 0 | if (!ndr_read_uint16(context, s, &res->NameType) || !ndr_read_uint16(context, s, &nameCount)) |
327 | 0 | return FALSE; |
328 | | |
329 | 0 | res->nameHints.count = nameCount; |
330 | |
|
331 | 0 | return ndr_read_refpointer(context, s, &names.ptrId) && ndr_push_deferreds(context, &names, 1); |
332 | 0 | } |
333 | | |
334 | | static BOOL ndr_descr_read_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, |
335 | | const void* hints, void* res) |
336 | 0 | { |
337 | 0 | return ndr_read_KERB_RPC_INTERNAL_NAME(context, s, hints, res); |
338 | 0 | } |
339 | | |
340 | | BOOL ndr_write_KERB_RPC_INTERNAL_NAME(NdrContext* context, wStream* s, const void* hints, |
341 | | const KERB_RPC_INTERNAL_NAME* res) |
342 | 0 | { |
343 | 0 | WINPR_UNUSED(context); |
344 | 0 | WINPR_UNUSED(s); |
345 | 0 | WINPR_UNUSED(hints); |
346 | 0 | WINPR_UNUSED(res); |
347 | 0 | WLog_ERR(TAG, "TODO: implement this"); |
348 | 0 | return FALSE; |
349 | 0 | } |
350 | | |
351 | | void ndr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel, |
352 | | const KERB_RPC_INTERNAL_NAME* obj) |
353 | 0 | { |
354 | 0 | WINPR_UNUSED(indentLevel); |
355 | 0 | WINPR_UNUSED(obj); |
356 | 0 | WLog_Print(logger, lvl, "TODO: implement this"); |
357 | 0 | } |
358 | | |
359 | | static void ndr_descr_dump_KERB_RPC_INTERNAL_NAME(wLog* logger, UINT32 lvl, size_t indentLevel, |
360 | | const void* obj) |
361 | 0 | { |
362 | 0 | ndr_dump_KERB_RPC_INTERNAL_NAME(logger, lvl, indentLevel, obj); |
363 | 0 | } |
364 | | |
365 | | void ndr_destroy_KERB_RPC_INTERNAL_NAME(NdrContext* context, const void* hints, |
366 | | KERB_RPC_INTERNAL_NAME* obj) |
367 | 0 | { |
368 | 0 | WINPR_UNUSED(hints); |
369 | 0 | if (!obj) |
370 | 0 | return; |
371 | | |
372 | 0 | for (UINT32 i = 0; i < obj->nameHints.count; i++) |
373 | 0 | ndr_destroy_RPC_UNICODE_STRING(context, NULL, &obj->Names[i]); |
374 | |
|
375 | 0 | free(obj->Names); |
376 | 0 | obj->Names = NULL; |
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 | | NULL, |
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) |