FreeRDP
Loading...
Searching...
No Matches
rdpear_common.h
1
19#ifndef FREERDP_CHANNEL_RDPEAR_COMMON_H
20#define FREERDP_CHANNEL_RDPEAR_COMMON_H
21
22#include <winpr/stream.h>
23#include <winpr/asn1.h>
24#include <winpr/wlog.h>
25#include <winpr/sspi.h>
26
27#include <freerdp/api.h>
28
29#include <rdpear-common/ndr.h>
30
31typedef enum
32{
33 RDPEAR_PACKAGE_KERBEROS,
34 RDPEAR_PACKAGE_NTLM,
35 RDPEAR_PACKAGE_UNKNOWN
36} RdpEarPackageType;
37
38/* RDPEAR 2.2.1.1 */
39typedef enum
40{
41 // Start Kerberos remote calls
42 RemoteCallKerbMinimum = 0x100,
43 RemoteCallKerbNegotiateVersion = 0x100,
44 RemoteCallKerbBuildAsReqAuthenticator,
45 RemoteCallKerbVerifyServiceTicket,
46 RemoteCallKerbCreateApReqAuthenticator,
47 RemoteCallKerbDecryptApReply,
48 RemoteCallKerbUnpackKdcReplyBody,
49 RemoteCallKerbComputeTgsChecksum,
50 RemoteCallKerbBuildEncryptedAuthData,
51 RemoteCallKerbPackApReply,
52 RemoteCallKerbHashS4UPreauth,
53 RemoteCallKerbSignS4UPreauthData,
54 RemoteCallKerbVerifyChecksum,
55 RemoteCallKerbReserved1,
56 RemoteCallKerbReserved2,
57 RemoteCallKerbReserved3,
58 RemoteCallKerbReserved4,
59 RemoteCallKerbReserved5,
60 RemoteCallKerbReserved6,
61 RemoteCallKerbReserved7,
62 RemoteCallKerbDecryptPacCredentials,
63 RemoteCallKerbCreateECDHKeyAgreement,
64 RemoteCallKerbCreateDHKeyAgreement,
65 RemoteCallKerbDestroyKeyAgreement,
66 RemoteCallKerbKeyAgreementGenerateNonce,
67 RemoteCallKerbFinalizeKeyAgreement,
68 RemoteCallKerbMaximum = 0x1ff,
69 // End Kerberos remote calls
70
71 // Start NTLM remote calls
72 RemoteCallNtlmMinimum = 0x200,
73 RemoteCallNtlmNegotiateVersion = 0x200,
74 RemoteCallNtlmLm20GetNtlm3ChallengeResponse,
75 RemoteCallNtlmCalculateNtResponse,
76 RemoteCallNtlmCalculateUserSessionKeyNt,
77 RemoteCallNtlmCompareCredentials,
78 RemoteCallNtlmMaximum = 0x2ff,
79 // End NTLM remote calls
80} RemoteGuardCallId;
81
82WINPR_ATTR_NODISCARD
83FREERDP_LOCAL RdpEarPackageType rdpear_packageType_from_name(const WinPrAsn1_OctetString* package);
84
85WINPR_ATTR_MALLOC(Stream_Free, 1)
86WINPR_ATTR_NODISCARD
87FREERDP_LOCAL wStream* rdpear_encodePayload(BOOL isKerb, wStream* payload);
88
89#define RDPEAR_COMMON_MESSAGE_DECL(V) \
90 WINPR_ATTR_NODISCARD \
91 FREERDP_LOCAL BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj); \
92 WINPR_ATTR_NODISCARD \
93 FREERDP_LOCAL BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, \
94 const V* obj); \
95 FREERDP_LOCAL void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj); \
96 FREERDP_LOCAL void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj); \
97 WINPR_ATTR_NODISCARD \
98 FREERDP_LOCAL NdrMessageType ndr_##V##_descr(void)
99
101typedef struct
102{
103 UINT32 length;
104 BYTE* value;
106
107RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_OCTET_STRING);
108
110typedef struct
111{
112 UINT32 Pdu;
113 NdrArrayHints Asn1BufferHints;
114 BYTE* Asn1Buffer;
116
117RDPEAR_COMMON_MESSAGE_DECL(KERB_ASN1_DATA);
118
120typedef struct
121{
122 NdrVaryingArrayHints lenHints;
123 UINT32 strLength;
124 WCHAR* Buffer;
126
127RDPEAR_COMMON_MESSAGE_DECL(RPC_UNICODE_STRING);
128
130typedef struct
131{
132 UINT16 NameType;
133 NdrArrayHints nameHints;
134 RPC_UNICODE_STRING* Names;
136
137RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_INTERNAL_NAME);
138
140typedef struct
141{
142 UINT32 reserved1;
143 UINT32 reserved2;
144 KERB_RPC_OCTET_STRING reserved3;
146
147RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_ENCRYPTION_KEY);
148
150typedef struct
151{
152 UINT32 KeyUsage;
154 KERB_ASN1_DATA* PlainAuthData;
156
157RDPEAR_COMMON_MESSAGE_DECL(BuildEncryptedAuthDataReq);
158
160typedef struct
161{
162 KERB_ASN1_DATA* requestBody;
164 UINT32 ChecksumType;
166
167RDPEAR_COMMON_MESSAGE_DECL(ComputeTgsChecksumReq);
168
170typedef struct
171{
172 KERB_RPC_ENCRYPTION_KEY* EncryptionKey;
173 ULONG SequenceNumber;
174 KERB_RPC_INTERNAL_NAME* ClientName;
175 RPC_UNICODE_STRING* ClientRealm;
176 PLARGE_INTEGER SkewTime;
177 KERB_RPC_ENCRYPTION_KEY* SubKey; // optional
178 KERB_ASN1_DATA* AuthData; // optional
179 KERB_ASN1_DATA* GssChecksum; // optional
180 ULONG KeyUsage;
182
183RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorReq);
184
186typedef struct
187{
188 LARGE_INTEGER AuthenticatorTime;
189 KERB_ASN1_DATA Authenticator;
190 LONG KerbProtocolError;
192
193RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorResp);
194
196typedef struct
197{
198 KERB_ASN1_DATA* EncryptedData;
200 KERB_RPC_ENCRYPTION_KEY* StrengthenKey;
201 ULONG Pdu;
202 ULONG KeyUsage;
204
205RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyReq);
206
208typedef struct
209{
210 LONG KerbProtocolError;
211 KERB_ASN1_DATA ReplyBody;
213
214RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyResp);
215
216typedef struct
217{
218 KERB_ASN1_DATA* EncryptedReply;
221
222RDPEAR_COMMON_MESSAGE_DECL(DecryptApReplyReq);
223
224typedef struct
225{
226 KERB_ASN1_DATA* Reply;
227 KERB_ASN1_DATA* ReplyBody;
228 KERB_RPC_ENCRYPTION_KEY* SessionKey;
230
231RDPEAR_COMMON_MESSAGE_DECL(PackApReplyReq);
232
233typedef struct
234{
235 NdrArrayHints PackedReplyHints;
236 BYTE* PackedReply;
238
239RDPEAR_COMMON_MESSAGE_DECL(PackApReplyResp);
240
241#undef RDPEAR_COMMON_MESSAGE_DECL
242
243#endif /* FREERDP_CHANNEL_RDPEAR_COMMON_H */
2.2.2.1.8 BuildEncryptedAuthData
2.2.2.1.7 ComputeTgsChecksum
2.2.2.1.4 CreateApReqAuthenticator
2.2.2.1.4 CreateApReqAuthenticator
2.2.1.2.1 KERB_ASN1_DATA
2.2.1.2.8 KERB_RPC_ENCRYPTION_KEY
2.2.1.2.3 KERB_RPC_INTERNAL_NAME
2.2.1.2.2 KERB_RPC_OCTET_STRING
hints for a conformant array
Definition ndr.h:210
hints for a varying conformant array
Definition ndr.h:195
2.3.10 RPC_UNICODE_STRING (MS-DTYP)
2.2.2.1.6 UnpackKdcReplyBody
2.2.2.1.6 UnpackKdcReplyBody