18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * fs/cifs/ntlmssp.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) International Business Machines Corp., 2002,2007 58c2ecf20Sopenharmony_ci * Author(s): Steve French (sfrench@us.ibm.com) 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This library is free software; you can redistribute it and/or modify 88c2ecf20Sopenharmony_ci * it under the terms of the GNU Lesser General Public License as published 98c2ecf20Sopenharmony_ci * by the Free Software Foundation; either version 2.1 of the License, or 108c2ecf20Sopenharmony_ci * (at your option) any later version. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This library is distributed in the hope that it will be useful, 138c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 148c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 158c2ecf20Sopenharmony_ci * the GNU Lesser General Public License for more details. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public License 188c2ecf20Sopenharmony_ci * along with this library; if not, write to the Free Software 198c2ecf20Sopenharmony_ci * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define NTLMSSP_SIGNATURE "NTLMSSP" 238c2ecf20Sopenharmony_ci/* Message Types */ 248c2ecf20Sopenharmony_ci#define NtLmNegotiate cpu_to_le32(1) 258c2ecf20Sopenharmony_ci#define NtLmChallenge cpu_to_le32(2) 268c2ecf20Sopenharmony_ci#define NtLmAuthenticate cpu_to_le32(3) 278c2ecf20Sopenharmony_ci#define UnknownMessage cpu_to_le32(8) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Negotiate Flags */ 308c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_UNICODE 0x01 /* Text strings are unicode */ 318c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_OEM 0x02 /* Text strings are in OEM */ 328c2ecf20Sopenharmony_ci#define NTLMSSP_REQUEST_TARGET 0x04 /* Srv returns its auth realm */ 338c2ecf20Sopenharmony_ci/* define reserved9 0x08 */ 348c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_SIGN 0x0010 /* Request signing capability */ 358c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_SEAL 0x0020 /* Request confidentiality */ 368c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_DGRAM 0x0040 378c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_LM_KEY 0x0080 /* Use LM session key */ 388c2ecf20Sopenharmony_ci/* defined reserved 8 0x0100 */ 398c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_NTLM 0x0200 /* NTLM authentication */ 408c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_NT_ONLY 0x0400 /* Lanman not allowed */ 418c2ecf20Sopenharmony_ci#define NTLMSSP_ANONYMOUS 0x0800 428c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x1000 /* reserved6 */ 438c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000 448c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000 /* client/server same machine */ 458c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000 /* Sign. All security levels */ 468c2ecf20Sopenharmony_ci#define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000 478c2ecf20Sopenharmony_ci#define NTLMSSP_TARGET_TYPE_SERVER 0x20000 488c2ecf20Sopenharmony_ci#define NTLMSSP_TARGET_TYPE_SHARE 0x40000 498c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_EXTENDED_SEC 0x80000 /* NB:not related to NTLMv2 pwd*/ 508c2ecf20Sopenharmony_ci/* #define NTLMSSP_REQUEST_INIT_RESP 0x100000 */ 518c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_IDENTIFY 0x100000 528c2ecf20Sopenharmony_ci#define NTLMSSP_REQUEST_ACCEPT_RESP 0x200000 /* reserved5 */ 538c2ecf20Sopenharmony_ci#define NTLMSSP_REQUEST_NON_NT_KEY 0x400000 548c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x800000 558c2ecf20Sopenharmony_ci/* #define reserved4 0x1000000 */ 568c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_VERSION 0x2000000 /* we do not set */ 578c2ecf20Sopenharmony_ci/* #define reserved3 0x4000000 */ 588c2ecf20Sopenharmony_ci/* #define reserved2 0x8000000 */ 598c2ecf20Sopenharmony_ci/* #define reserved1 0x10000000 */ 608c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_128 0x20000000 618c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000 628c2ecf20Sopenharmony_ci#define NTLMSSP_NEGOTIATE_56 0x80000000 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Define AV Pair Field IDs */ 658c2ecf20Sopenharmony_cienum av_field_type { 668c2ecf20Sopenharmony_ci NTLMSSP_AV_EOL = 0, 678c2ecf20Sopenharmony_ci NTLMSSP_AV_NB_COMPUTER_NAME, 688c2ecf20Sopenharmony_ci NTLMSSP_AV_NB_DOMAIN_NAME, 698c2ecf20Sopenharmony_ci NTLMSSP_AV_DNS_COMPUTER_NAME, 708c2ecf20Sopenharmony_ci NTLMSSP_AV_DNS_DOMAIN_NAME, 718c2ecf20Sopenharmony_ci NTLMSSP_AV_DNS_TREE_NAME, 728c2ecf20Sopenharmony_ci NTLMSSP_AV_FLAGS, 738c2ecf20Sopenharmony_ci NTLMSSP_AV_TIMESTAMP, 748c2ecf20Sopenharmony_ci NTLMSSP_AV_RESTRICTION, 758c2ecf20Sopenharmony_ci NTLMSSP_AV_TARGET_NAME, 768c2ecf20Sopenharmony_ci NTLMSSP_AV_CHANNEL_BINDINGS 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Although typedefs are not commonly used for structure definitions */ 808c2ecf20Sopenharmony_ci/* in the Linux kernel, in this particular case they are useful */ 818c2ecf20Sopenharmony_ci/* to more closely match the standards document for NTLMSSP from */ 828c2ecf20Sopenharmony_ci/* OpenGroup and to make the code more closely match the standard in */ 838c2ecf20Sopenharmony_ci/* appearance */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_citypedef struct _SECURITY_BUFFER { 868c2ecf20Sopenharmony_ci __le16 Length; 878c2ecf20Sopenharmony_ci __le16 MaximumLength; 888c2ecf20Sopenharmony_ci __le32 BufferOffset; /* offset to buffer */ 898c2ecf20Sopenharmony_ci} __attribute__((packed)) SECURITY_BUFFER; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_citypedef struct _NEGOTIATE_MESSAGE { 928c2ecf20Sopenharmony_ci __u8 Signature[sizeof(NTLMSSP_SIGNATURE)]; 938c2ecf20Sopenharmony_ci __le32 MessageType; /* NtLmNegotiate = 1 */ 948c2ecf20Sopenharmony_ci __le32 NegotiateFlags; 958c2ecf20Sopenharmony_ci SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */ 968c2ecf20Sopenharmony_ci SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */ 978c2ecf20Sopenharmony_ci /* SECURITY_BUFFER for version info not present since we 988c2ecf20Sopenharmony_ci do not set the version is present flag */ 998c2ecf20Sopenharmony_ci char DomainString[0]; 1008c2ecf20Sopenharmony_ci /* followed by WorkstationString */ 1018c2ecf20Sopenharmony_ci} __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_citypedef struct _CHALLENGE_MESSAGE { 1048c2ecf20Sopenharmony_ci __u8 Signature[sizeof(NTLMSSP_SIGNATURE)]; 1058c2ecf20Sopenharmony_ci __le32 MessageType; /* NtLmChallenge = 2 */ 1068c2ecf20Sopenharmony_ci SECURITY_BUFFER TargetName; 1078c2ecf20Sopenharmony_ci __le32 NegotiateFlags; 1088c2ecf20Sopenharmony_ci __u8 Challenge[CIFS_CRYPTO_KEY_SIZE]; 1098c2ecf20Sopenharmony_ci __u8 Reserved[8]; 1108c2ecf20Sopenharmony_ci SECURITY_BUFFER TargetInfoArray; 1118c2ecf20Sopenharmony_ci /* SECURITY_BUFFER for version info not present since we 1128c2ecf20Sopenharmony_ci do not set the version is present flag */ 1138c2ecf20Sopenharmony_ci} __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_citypedef struct _AUTHENTICATE_MESSAGE { 1168c2ecf20Sopenharmony_ci __u8 Signature[sizeof(NTLMSSP_SIGNATURE)]; 1178c2ecf20Sopenharmony_ci __le32 MessageType; /* NtLmsAuthenticate = 3 */ 1188c2ecf20Sopenharmony_ci SECURITY_BUFFER LmChallengeResponse; 1198c2ecf20Sopenharmony_ci SECURITY_BUFFER NtChallengeResponse; 1208c2ecf20Sopenharmony_ci SECURITY_BUFFER DomainName; 1218c2ecf20Sopenharmony_ci SECURITY_BUFFER UserName; 1228c2ecf20Sopenharmony_ci SECURITY_BUFFER WorkstationName; 1238c2ecf20Sopenharmony_ci SECURITY_BUFFER SessionKey; 1248c2ecf20Sopenharmony_ci __le32 NegotiateFlags; 1258c2ecf20Sopenharmony_ci /* SECURITY_BUFFER for version info not present since we 1268c2ecf20Sopenharmony_ci do not set the version is present flag */ 1278c2ecf20Sopenharmony_ci char UserString[0]; 1288c2ecf20Sopenharmony_ci} __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* 1318c2ecf20Sopenharmony_ci * Size of the session key (crypto key encrypted with the password 1328c2ecf20Sopenharmony_ci */ 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ciint decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses); 1358c2ecf20Sopenharmony_civoid build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses); 1368c2ecf20Sopenharmony_ciint build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen, 1378c2ecf20Sopenharmony_ci struct cifs_ses *ses, 1388c2ecf20Sopenharmony_ci const struct nls_table *nls_cp); 139