1 /* SPDX-License-Identifier: LGPL-2.1 */
5 * Copyright (c) International Business Machines Corp., 2002,2007
6 * Author(s): Steve French (sfrench@us.ibm.com)
10 #define NTLMSSP_SIGNATURE "NTLMSSP"
12 #define NtLmNegotiate cpu_to_le32(1)
13 #define NtLmChallenge cpu_to_le32(2)
14 #define NtLmAuthenticate cpu_to_le32(3)
15 #define UnknownMessage cpu_to_le32(8)
18 #define NTLMSSP_NEGOTIATE_UNICODE 0x01 /* Text strings are unicode */
19 #define NTLMSSP_NEGOTIATE_OEM 0x02 /* Text strings are in OEM */
20 #define NTLMSSP_REQUEST_TARGET 0x04 /* Srv returns its auth realm */
21 /* define reserved9 0x08 */
22 #define NTLMSSP_NEGOTIATE_SIGN 0x0010 /* Request signing capability */
23 #define NTLMSSP_NEGOTIATE_SEAL 0x0020 /* Request confidentiality */
24 #define NTLMSSP_NEGOTIATE_DGRAM 0x0040
25 #define NTLMSSP_NEGOTIATE_LM_KEY 0x0080 /* Use LM session key */
26 /* defined reserved 8 0x0100 */
27 #define NTLMSSP_NEGOTIATE_NTLM 0x0200 /* NTLM authentication */
28 #define NTLMSSP_NEGOTIATE_NT_ONLY 0x0400 /* Lanman not allowed */
29 #define NTLMSSP_ANONYMOUS 0x0800
30 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x1000 /* reserved6 */
31 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000
32 #define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000 /* client/server same machine */
33 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000 /* Sign. All security levels */
34 #define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000
35 #define NTLMSSP_TARGET_TYPE_SERVER 0x20000
36 #define NTLMSSP_TARGET_TYPE_SHARE 0x40000
37 #define NTLMSSP_NEGOTIATE_EXTENDED_SEC 0x80000 /* NB:not related to NTLMv2 pwd*/
38 /* #define NTLMSSP_REQUEST_INIT_RESP 0x100000 */
39 #define NTLMSSP_NEGOTIATE_IDENTIFY 0x100000
40 #define NTLMSSP_REQUEST_ACCEPT_RESP 0x200000 /* reserved5 */
41 #define NTLMSSP_REQUEST_NON_NT_KEY 0x400000
42 #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x800000
43 /* #define reserved4 0x1000000 */
44 #define NTLMSSP_NEGOTIATE_VERSION 0x2000000 /* we do not set */
45 /* #define reserved3 0x4000000 */
46 /* #define reserved2 0x8000000 */
47 /* #define reserved1 0x10000000 */
48 #define NTLMSSP_NEGOTIATE_128 0x20000000
49 #define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000
50 #define NTLMSSP_NEGOTIATE_56 0x80000000
52 /* Define AV Pair Field IDs */
55 NTLMSSP_AV_NB_COMPUTER_NAME,
56 NTLMSSP_AV_NB_DOMAIN_NAME,
57 NTLMSSP_AV_DNS_COMPUTER_NAME,
58 NTLMSSP_AV_DNS_DOMAIN_NAME,
59 NTLMSSP_AV_DNS_TREE_NAME,
62 NTLMSSP_AV_RESTRICTION,
63 NTLMSSP_AV_TARGET_NAME,
64 NTLMSSP_AV_CHANNEL_BINDINGS
67 /* Although typedefs are not commonly used for structure definitions */
68 /* in the Linux kernel, in this particular case they are useful */
69 /* to more closely match the standards document for NTLMSSP from */
70 /* OpenGroup and to make the code more closely match the standard in */
73 typedef struct _SECURITY_BUFFER {
76 __le32 BufferOffset; /* offset to buffer */
77 } __attribute__((packed)) SECURITY_BUFFER;
79 typedef struct _NEGOTIATE_MESSAGE {
80 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
81 __le32 MessageType; /* NtLmNegotiate = 1 */
82 __le32 NegotiateFlags;
83 SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */
84 SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */
85 /* SECURITY_BUFFER for version info not present since we
86 do not set the version is present flag */
88 /* followed by WorkstationString */
89 } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
91 typedef struct _CHALLENGE_MESSAGE {
92 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
93 __le32 MessageType; /* NtLmChallenge = 2 */
94 SECURITY_BUFFER TargetName;
95 __le32 NegotiateFlags;
96 __u8 Challenge[CIFS_CRYPTO_KEY_SIZE];
98 SECURITY_BUFFER TargetInfoArray;
99 /* SECURITY_BUFFER for version info not present since we
100 do not set the version is present flag */
101 } __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE;
103 typedef struct _AUTHENTICATE_MESSAGE {
104 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
105 __le32 MessageType; /* NtLmsAuthenticate = 3 */
106 SECURITY_BUFFER LmChallengeResponse;
107 SECURITY_BUFFER NtChallengeResponse;
108 SECURITY_BUFFER DomainName;
109 SECURITY_BUFFER UserName;
110 SECURITY_BUFFER WorkstationName;
111 SECURITY_BUFFER SessionKey;
112 __le32 NegotiateFlags;
113 /* SECURITY_BUFFER for version info not present since we
114 do not set the version is present flag */
116 } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
119 * Size of the session key (crypto key encrypted with the password
122 int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
123 void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses);
124 int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
125 struct cifs_ses *ses,
126 const struct nls_table *nls_cp);