FreeRDP
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 
31 typedef enum
32 {
33  RDPEAR_PACKAGE_KERBEROS,
34  RDPEAR_PACKAGE_NTLM,
35  RDPEAR_PACKAGE_UNKNOWN
36 } RdpEarPackageType;
37 
38 /* RDPEAR 2.2.1.1 */
39 typedef 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 
82 FREERDP_LOCAL RdpEarPackageType rdpear_packageType_from_name(WinPrAsn1_OctetString* package);
83 FREERDP_LOCAL wStream* rdpear_encodePayload(RdpEarPackageType packageType, wStream* payload);
84 
85 #define RDPEAR_COMMON_MESSAGE_DECL(V) \
86  FREERDP_LOCAL BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj); \
87  FREERDP_LOCAL BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, \
88  const V* obj); \
89  FREERDP_LOCAL void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj); \
90  FREERDP_LOCAL void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj); \
91  FREERDP_LOCAL NdrMessageType ndr_##V##_descr(void)
92 
94 typedef struct
95 {
96  UINT32 length;
97  BYTE* value;
99 
100 RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_OCTET_STRING);
101 
103 typedef struct
104 {
105  UINT32 Pdu;
106  NdrArrayHints Asn1BufferHints;
107  BYTE* Asn1Buffer;
109 
110 RDPEAR_COMMON_MESSAGE_DECL(KERB_ASN1_DATA);
111 
113 typedef struct
114 {
115  NdrVaryingArrayHints lenHints;
116  UINT32 strLength;
117  WCHAR* Buffer;
119 
120 RDPEAR_COMMON_MESSAGE_DECL(RPC_UNICODE_STRING);
121 
123 typedef struct
124 {
125  UINT16 NameType;
126  NdrArrayHints nameHints;
127  RPC_UNICODE_STRING* Names;
129 
130 RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_INTERNAL_NAME);
131 
133 typedef struct
134 {
135  UINT32 reserved1;
136  UINT32 reserved2;
137  KERB_RPC_OCTET_STRING reserved3;
139 
140 RDPEAR_COMMON_MESSAGE_DECL(KERB_RPC_ENCRYPTION_KEY);
141 
143 typedef struct
144 {
145  UINT32 KeyUsage;
147  KERB_ASN1_DATA* PlainAuthData;
149 
150 RDPEAR_COMMON_MESSAGE_DECL(BuildEncryptedAuthDataReq);
151 
153 typedef struct
154 {
155  KERB_ASN1_DATA* requestBody;
157  UINT32 ChecksumType;
159 
160 RDPEAR_COMMON_MESSAGE_DECL(ComputeTgsChecksumReq);
161 
163 typedef struct
164 {
165  KERB_RPC_ENCRYPTION_KEY* EncryptionKey;
166  ULONG SequenceNumber;
167  KERB_RPC_INTERNAL_NAME* ClientName;
168  RPC_UNICODE_STRING* ClientRealm;
169  PLARGE_INTEGER SkewTime;
170  KERB_RPC_ENCRYPTION_KEY* SubKey; // optional
171  KERB_ASN1_DATA* AuthData; // optional
172  KERB_ASN1_DATA* GssChecksum; // optional
173  ULONG KeyUsage;
175 
176 RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorReq);
177 
179 typedef struct
180 {
181  LARGE_INTEGER AuthenticatorTime;
182  KERB_ASN1_DATA Authenticator;
183  LONG KerbProtocolError;
185 
186 RDPEAR_COMMON_MESSAGE_DECL(CreateApReqAuthenticatorResp);
187 
189 typedef struct
190 {
191  KERB_ASN1_DATA* EncryptedData;
193  KERB_RPC_ENCRYPTION_KEY* StrengthenKey;
194  ULONG Pdu;
195  ULONG KeyUsage;
197 
198 RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyReq);
199 
201 typedef struct
202 {
203  LONG KerbProtocolError;
204  KERB_ASN1_DATA ReplyBody;
206 
207 RDPEAR_COMMON_MESSAGE_DECL(UnpackKdcReplyBodyResp);
208 
209 typedef struct
210 {
211  KERB_ASN1_DATA* EncryptedReply;
214 
215 RDPEAR_COMMON_MESSAGE_DECL(DecryptApReplyReq);
216 
217 typedef struct
218 {
219  KERB_ASN1_DATA* Reply;
220  KERB_ASN1_DATA* ReplyBody;
221  KERB_RPC_ENCRYPTION_KEY* SessionKey;
223 
224 RDPEAR_COMMON_MESSAGE_DECL(PackApReplyReq);
225 
226 typedef struct
227 {
228  NdrArrayHints PackedReplyHints;
229  BYTE* PackedReply;
231 
232 RDPEAR_COMMON_MESSAGE_DECL(PackApReplyResp);
233 
234 #undef RDPEAR_COMMON_MESSAGE_DECL
235 
236 #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
Definition: rdpear_common.h:95
hints for a conformant array
Definition: ndr.h:184
hints for a varying conformant array
Definition: ndr.h:170
2.3.10 RPC_UNICODE_STRING (MS-DTYP)
2.2.2.1.6 UnpackKdcReplyBody
2.2.2.1.6 UnpackKdcReplyBody