dd42da092540d63c3ab561f5b1e3f9eac4a9d3d5
[ira/wip.git] / librpc / idl / ntlmssp.idl
1 #include "idl_types.h"
2
3 /*
4   ntlmssp interface definition
5 */
6
7 [
8         pointer_default(unique),
9         helper("../librpc/ndr/ndr_ntlmssp.h")
10 ]
11 interface ntlmssp
12 {
13         typedef [v1_enum] enum {
14                 NtLmNegotiate           = 0x00000001,
15                 NtLmChallenge           = 0x00000002,
16                 NtLmAuthenticate        = 0x00000003
17         } ntlmssp_MessageType;
18
19         typedef [bitmap32bit] bitmap {
20                 NTLMSSP_NEGOTIATE_UNICODE                       = 0x00000001,
21                 NTLMSSP_NEGOTIATE_OEM                           = 0x00000002, /* NTLM_NEGOTIATE_OEM in MS-NLMP */
22                 NTLMSSP_REQUEST_TARGET                          = 0x00000004,
23                 NTLMSSP_NEGOTIATE_SIGN                          = 0x00000010, /* Message integrity */
24                 NTLMSSP_NEGOTIATE_SEAL                          = 0x00000020, /* Message confidentiality */
25                 NTLMSSP_NEGOTIATE_DATAGRAM                      = 0x00000040,
26                 NTLMSSP_NEGOTIATE_LM_KEY                        = 0x00000080,
27                 NTLMSSP_NEGOTIATE_NETWARE                       = 0x00000100, /* not mentioned in MS-NLMP */
28                 NTLMSSP_NEGOTIATE_NTLM                          = 0x00000200,
29                 NTLMSSP_NEGOTIATE_NT_ONLY                       = 0x00000400,
30                 NTLMSSP_ANONYMOUS                               = 0x00000800, /* no symbol name in MS-NLMP */
31                 NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED           = 0x00001000,
32                 NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED      = 0x00002000,
33                 NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL            = 0x00004000, /* not mentioned in MS-NLMP */
34                 NTLMSSP_NEGOTIATE_ALWAYS_SIGN                   = 0x00008000,
35                 NTLMSSP_TARGET_TYPE_DOMAIN                      = 0x00010000,
36                 NTLMSSP_TARGET_TYPE_SERVER                      = 0x00020000,
37                 NTLMSSP_TARGET_TYPE_SHARE                       = 0x00040000,
38                 NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY      = 0x00080000,
39                 NTLMSSP_NEGOTIATE_IDENTIFY                      = 0x00100000,
40                 NTLMSSP_REQUEST_NON_NT_SESSION_KEY              = 0x00400000,
41                 NTLMSSP_NEGOTIATE_TARGET_INFO                   = 0x00800000,
42                 NTLMSSP_NEGOTIATE_VERSION                       = 0x02000000,
43                 NTLMSSP_NEGOTIATE_128                           = 0x20000000, /* 128-bit encryption */
44                 NTLMSSP_NEGOTIATE_KEY_EXCH                      = 0x40000000,
45                 NTLMSSP_NEGOTIATE_56                            = 0x80000000
46         } NEGOTIATE;
47
48         /* convenience mapping */
49         const int NTLMSSP_NEGOTIATE_NTLM2 = NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY;
50
51         /*
52            NTLMSSP_WINDOWS_MAJOR_VERSION_5: Windows XP SP2 and Server 2003
53            NTLMSSP_WINDOWS_MAJOR_VERSION_6: Windows Vista, Server 2008, 7 and Server 2008 R2
54          */
55
56         typedef [enum8bit] enum {
57                 NTLMSSP_WINDOWS_MAJOR_VERSION_5 = 0x05,
58                 NTLMSSP_WINDOWS_MAJOR_VERSION_6 = 0x06
59         } ntlmssp_WindowsMajorVersion;
60
61         /*
62            NTLMSSP_WINDOWS_MINOR_VERSION_0: Windows Vista, Server 2008, 7, Server 2008 R2
63            NTLMSSP_WINDOWS_MINOR_VERSION_1: Windows XP SP2
64            NTLMSSP_WINDOWS_MINOR_VERSION_2: Windows Server 2003
65          */
66
67         typedef [enum8bit] enum {
68                 NTLMSSP_WINDOWS_MINOR_VERSION_0 = 0x00,
69                 NTLMSSP_WINDOWS_MINOR_VERSION_1 = 0x01,
70                 NTLMSSP_WINDOWS_MINOR_VERSION_2 = 0x02
71         } ntlmssp_WindowsMinorVersion;
72
73         /*
74            NTLMSSP_REVISION_W2K3_RC1:
75            NTLMSSP_REVISION_W2K3: Windows XP SP2, Server 2003, Vista, Server 2008, 7, Server 2008 R2
76          */
77
78         typedef [enum8bit] enum {
79                 NTLMSSP_REVISION_W2K3_RC1       = 0x0A,
80                 NTLMSSP_REVISION_W2K3           = 0x0F
81         } ntlmssp_NTLMRevisionCurrent;
82
83         typedef struct {
84                 ntlmssp_WindowsMajorVersion ProductMajorVersion;
85                 ntlmssp_WindowsMinorVersion ProductMinorVersion;
86                 uint16 ProductBuild;
87                 uint8 Reserved[3];
88                 ntlmssp_NTLMRevisionCurrent NTLMRevisionCurrent;
89         } VERSION;
90
91         typedef [nodiscriminant] union {
92                 [case(NTLMSSP_NEGOTIATE_VERSION)] VERSION version;
93                 [default];
94         } ntlmssp_Version;
95
96         /* NTLMSSP negotiate message */
97
98         typedef [public] struct {
99                 [charset(DOS),value("NTLMSSP")] uint8 Signature[8];
100                 [value(NtLmNegotiate)] ntlmssp_MessageType MessageType;
101                 NEGOTIATE NegotiateFlags;
102                 [value(strlen(DomainName))] uint16 DomainNameLen;
103                 [value(DomainNameLen)] uint16 DomainNameMaxLen;
104                 [relative] [subcontext(0),subcontext_size(DomainNameLen)] [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_OEM))] string *DomainName;
105                 [value(strlen(Workstation))] uint16 WorkstationLen;
106                 [value(WorkstationLen)] uint16 WorkstationMaxLen;
107                 [relative] [subcontext(0),subcontext_size(WorkstationLen)] [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_OEM))] string *Workstation;
108                 [switch_is(NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)] ntlmssp_Version Version;
109         } NEGOTIATE_MESSAGE;
110
111         typedef enum {
112                 MsvAvEOL                = 0,
113                 MsvAvNbComputerName     = 1,
114                 MsvAvNbDomainName       = 2,
115                 MsvAvDnsComputerName    = 3,
116                 MsvAvDnsDomainName      = 4,
117                 MsvAvDnsTreeName        = 5,
118                 MsvAvFlags              = 6,
119                 MsvAvTimestamp          = 7,
120                 MsAvRestrictions        = 8,
121                 MsvAvTargetName         = 9,
122                 MsvChannelBindings      = 10
123         } ntlmssp_AvId;
124
125         typedef struct {
126                 uint32 Size;
127                 [value(0)] uint32 Z4;
128                 boolean32 IntegrityLevel;
129                 uint32 SubjectIntegrityLevel;
130                 uint8 MachineId[32];
131         } Restriction_Encoding;
132
133         typedef [bitmap32bit] bitmap {
134                 NTLMSSP_AVFLAG_CONSTRAINTED_ACCOUNT             = 0x00000001,
135                 NTLMSSP_AVFLAG_MIC_IN_AUTHENTICATE_MESSAGE      = 0x00000002
136         } ntlmssp_AvFlags;
137
138         typedef [gensize,nodiscriminant,flag(NDR_NOALIGN)] union {
139                 [case(MsvAvEOL)]                ;
140                 [case(MsvAvNbComputerName)]     [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvNbComputerName;
141                 [case(MsvAvNbDomainName)]       [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvNbDomainName;
142                 [case(MsvAvDnsComputerName)]    [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvDnsComputerName;
143                 [case(MsvAvDnsDomainName)]      [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvDnsDomainName;
144                 [case(MsvAvDnsTreeName)]        [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvDnsTreeName;
145                 [case(MsvAvFlags)]              ntlmssp_AvFlags AvFlags;
146                 [case(MsvAvTimestamp)]          NTTIME AvTimestamp;
147                 [case(MsAvRestrictions)]        Restriction_Encoding AvRestrictions;
148                 [case(MsvAvTargetName)]         [flag(ndr_ntlmssp_negotiated_string_flags(NTLMSSP_NEGOTIATE_UNICODE))] string AvTargetName;
149                 [case(MsvChannelBindings)]      uint8 ChannelBindings[16];
150                 [default]                       [flag(NDR_REMAINING)] DATA_BLOB blob;
151         } ntlmssp_AvValue;
152
153         typedef [public,flag(NDR_NOALIGN)] struct {
154                 ntlmssp_AvId AvId;
155                 [value(ndr_size_ntlmssp_AvValue(&r->Value, r->AvId, ndr->iconv_convenience, 0))] uint16 AvLen;
156                 [subcontext(0),subcontext_size(AvLen),switch_is(AvId)] ntlmssp_AvValue Value;
157         } AV_PAIR;
158
159         typedef [gensize,nopush,nopull,flag(NDR_NOALIGN)] struct {
160                 uint32 count;
161                 AV_PAIR pair[count];
162         } AV_PAIR_LIST;
163
164         /* NTLMSSP challenge message */
165
166         typedef [public,flag(NDR_PAHEX)] struct {
167                 [charset(DOS),value("NTLMSSP")] uint8 Signature[8];
168                 [value(NtLmChallenge)] ntlmssp_MessageType MessageType;
169                 [value(ndr_ntlmssp_string_length(NegotiateFlags, TargetName))] uint16 TargetNameLen;
170                 [value(TargetNameLen)] uint16 TargetNameMaxLen;
171                 [relative] [subcontext(0),subcontext_size(TargetNameLen)] [flag(ndr_ntlmssp_negotiated_string_flags(r->NegotiateFlags))] string *TargetName;
172                 NEGOTIATE NegotiateFlags;
173                 uint8 ServerChallenge[8];
174                 uint8 Reserved[8];
175                 [value(ndr_size_AV_PAIR_LIST(TargetInfo, ndr->iconv_convenience, ndr->flags))] uint16 TargetInfoLen;
176                 [value(TargetInfoLen)] uint16 TargetNameInfoMaxLen;
177                 [relative] [subcontext(0),subcontext_size(TargetInfoLen)] AV_PAIR_LIST *TargetInfo;
178                 [switch_is(NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)] ntlmssp_Version Version;
179         } CHALLENGE_MESSAGE;
180
181         typedef [public,flag(NDR_PAHEX)] struct {
182                 uint8 Response[24];
183         } LM_RESPONSE;
184
185         typedef [public,flag(NDR_PAHEX)] struct {
186                 uint8 Response[16];
187                 uint8 ChallengeFromClient[8];
188         } LMv2_RESPONSE;
189
190         typedef [nodiscriminant] union {
191                 [case(24)] LM_RESPONSE v1;
192                 [default];
193         } ntlmssp_LM_RESPONSE;
194
195         typedef [public,flag(NDR_PAHEX)] struct {
196                 uint8 Response[24];
197         } NTLM_RESPONSE;
198
199         typedef [flag(NDR_PAHEX)] struct {
200                 [value(1)] uint8 RespType;
201                 [value(1)] uint8 HiRespType;
202                 uint16 Reserved1;
203                 uint32 Reserved2;
204                 NTTIME TimeStamp;
205                 uint8 ChallengeFromClient[8];
206                 uint32 Reserved3;
207                 [subcontext(0)] [flag(NDR_REMAINING)] AV_PAIR_LIST AvPairs;
208         } NTLMv2_CLIENT_CHALLENGE;
209
210         typedef [public,flag(NDR_PAHEX)] struct {
211                 uint8 Response[16];
212                 NTLMv2_CLIENT_CHALLENGE Challenge;
213         } NTLMv2_RESPONSE;
214
215         typedef [public,nodiscriminant] union {
216                 [case(0)] ;
217                 [case(0x18)] NTLM_RESPONSE v1;
218                 [default] NTLMv2_RESPONSE v2;
219         } ntlmssp_NTLM_RESPONSE;
220
221         typedef [flag(NDR_PAHEX)] struct {
222                 uint8 MIC[16];
223         } MIC;
224
225         /* NTLMSSP authenticate message */
226
227         typedef [public,flag(NDR_REMAINING)] struct {
228                 [charset(DOS),value("NTLMSSP")] uint8 Signature[8];
229                 [value(NtLmAuthenticate)] ntlmssp_MessageType MessageType;
230                 uint16 LmChallengeResponseLen;
231                 [value(LmChallengeResponseLen)] uint16 LmChallengeResponseMaxLen;
232                 [relative] [subcontext(0),subcontext_size(LmChallengeResponseLen),switch_is(LmChallengeResponseLen)] ntlmssp_LM_RESPONSE *LmChallengeResponse;
233                 uint16 NtChallengeResponseLen;
234                 [value(NtChallengeResponseLen)] uint16 NtChallengeResponseMaxLen;
235                 [relative] [subcontext(0),subcontext_size(NtChallengeResponseMaxLen),switch_is(NtChallengeResponseLen)] ntlmssp_NTLM_RESPONSE *NtChallengeResponse;
236                 [value(ndr_ntlmssp_string_length(NegotiateFlags, DomainName))] uint16 DomainNameLen;
237                 [value(DomainNameLen)] uint16 DomainNameMaxLen;
238                 [relative] [subcontext(0),subcontext_size(DomainNameLen)] [flag(ndr_ntlmssp_negotiated_string_flags(r->NegotiateFlags))] string *DomainName;
239                 [value(ndr_ntlmssp_string_length(NegotiateFlags, UserName))] uint16 UserNameLen;
240                 [value(UserNameLen)] uint16 UserNameMaxLen;
241                 [relative] [subcontext(0),subcontext_size(UserNameLen)] [flag(ndr_ntlmssp_negotiated_string_flags(r->NegotiateFlags))] string *UserName;
242                 [value(ndr_ntlmssp_string_length(NegotiateFlags, Workstation))] uint16 WorkstationLen;
243                 [value(WorkstationLen)] uint16 WorkstationMaxLen;
244                 [relative] [subcontext(0),subcontext_size(WorkstationLen)] [flag(ndr_ntlmssp_negotiated_string_flags(r->NegotiateFlags))] string *Workstation;
245                 [value(EncryptedRandomSessionKey->length)] uint16 EncryptedRandomSessionKeyLen;
246                 [value(EncryptedRandomSessionKeyLen)] uint16 EncryptedRandomSessionKeyMaxLen;
247                 [relative] [subcontext(0),subcontext_size(EncryptedRandomSessionKeyLen)] DATA_BLOB *EncryptedRandomSessionKey;
248                 NEGOTIATE NegotiateFlags;
249                 [switch_is(NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)] ntlmssp_Version Version;
250                 /* MIC (Message Integrity) is only included when the client has
251                  * sent a timestap Av struct in the CHALLENGE_MESSAGE AvPair */
252                 /* [flag(NDR_REMAINING)] MIC mic; */
253         } AUTHENTICATE_MESSAGE;
254
255         /* NTLMSSP signature version */
256         const int NTLMSSP_SIGN_VERSION = 0x01;
257
258         /* NTLMSSP signature size */
259         const int NTLMSSP_SIG_SIZE = 16;
260
261         typedef [public] struct {
262                  [value(NTLMSSP_SIGN_VERSION)] uint32 Version;
263                  uint32 RandomPad;
264                  uint32 Checksum;
265                  uint32 SeqNum;
266         } NTLMSSP_MESSAGE_SIGNATURE;
267
268         typedef [public,flag(NDR_PAHEX)] struct {
269                  [value(NTLMSSP_SIGN_VERSION)] uint32 Version;
270                  uint8 Checksum[8];
271                  uint32 SeqNum;
272         } NTLMSSP_MESSAGE_SIGNATURE_NTLMv2;
273 }