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
82FREERDP_LOCAL RdpEarPackageType rdpear_packageType_from_name(const WinPrAsn1_OctetString* package);
83WINPR_ATTR_MALLOC(Stream_Free, 1)
84WINPR_ATTR_NODISCARD
85FREERDP_LOCAL wStream* rdpear_encodePayload(BOOL isKerb, wStream* payload);
86
87#define RDPEAR_COMMON_MESSAGE_DECL(V) \
88 FREERDP_LOCAL BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj); \
89 FREERDP_LOCAL BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, \
90 const V* obj); \
91 FREERDP_LOCAL void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj); \
92 FREERDP_LOCAL void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj); \
93 FREERDP_LOCAL NdrMessageType ndr_##V##_descr(void)
94
96typedef struct
97{
98 UINT32 length;
99 BYTE* value;
101
102RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_OCTET_STRING);
103
105typedef struct
106{
107 UINT32 Pdu;
108 NdrArrayHints Asn1BufferHints;
109 BYTE* Asn1Buffer;
111
112RDPEAR_COMMON_MESSAGE_DECL(KERB_ASN1_DATA);
113
115typedef struct
116{
117 NdrVaryingArrayHints lenHints;
118 UINT32 strLength;
119 WCHAR* Buffer;
121
122RDPEAR_COMMON_MESSAGE_DECL(RPC_UNICODE_STRING);
123
125typedef struct
126{
127 UINT16 NameType;
128 NdrArrayHints nameHints;
129 RPC_UNICODE_STRING* Names;
131
132RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_INTERNAL_NAME);
133
135typedef struct
136{
137 UINT32 reserved1;
138 UINT32 reserved2;
139 KERB_RPC_OCTET_STRING reserved3;
141
142RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_ENCRYPTION_KEY);
143
145typedef struct
146{
147 UINT32 KeyUsage;
149 KERB_ASN1_DATA* PlainAuthData;
151
152RDPEAR_COMMON_MESSAGE_DECL(BuildEncryptedAuthDataReq);
153
155typedef struct
156{
157 KERB_ASN1_DATA* requestBody;
159 UINT32 ChecksumType;
161
162RDPEAR_COMMON_MESSAGE_DECL(ComputeTgsChecksumReq);
163
165typedef struct
166{
167 KERB_RPC_ENCRYPTION_KEY* EncryptionKey;
168 ULONG SequenceNumber;
169 KERB_RPC_INTERNAL_NAME* ClientName;
170 RPC_UNICODE_STRING* ClientRealm;
171 PLARGE_INTEGER SkewTime;
172 KERB_RPC_ENCRYPTION_KEY* SubKey; // optional
173 KERB_ASN1_DATA* AuthData; // optional
174 KERB_ASN1_DATA* GssChecksum; // optional
175 ULONG KeyUsage;
177
178RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorReq);
179
181typedef struct
182{
183 LARGE_INTEGER AuthenticatorTime;
184 KERB_ASN1_DATA Authenticator;
185 LONG KerbProtocolError;
187
188RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorResp);
189
191typedef struct
192{
193 KERB_ASN1_DATA* EncryptedData;
195 KERB_RPC_ENCRYPTION_KEY* StrengthenKey;
196 ULONG Pdu;
197 ULONG KeyUsage;
199
200RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyReq);
201
203typedef struct
204{
205 LONG KerbProtocolError;
206 KERB_ASN1_DATA ReplyBody;
208
209RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyResp);
210
211typedef struct
212{
213 KERB_ASN1_DATA* EncryptedReply;
216
217RDPEAR_COMMON_MESSAGE_DECL(DecryptApReplyReq);
218
219typedef struct
220{
221 KERB_ASN1_DATA* Reply;
222 KERB_ASN1_DATA* ReplyBody;
223 KERB_RPC_ENCRYPTION_KEY* SessionKey;
225
226RDPEAR_COMMON_MESSAGE_DECL(PackApReplyReq);
227
228typedef struct
229{
230 NdrArrayHints PackedReplyHints;
231 BYTE* PackedReply;
233
234RDPEAR_COMMON_MESSAGE_DECL(PackApReplyResp);
235
236#undef RDPEAR_COMMON_MESSAGE_DECL
237
238#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:188
hints for a varying conformant array
Definition ndr.h:174
2.3.10 RPC_UNICODE_STRING (MS-DTYP)
2.2.2.1.6 UnpackKdcReplyBody
2.2.2.1.6 UnpackKdcReplyBody