^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * fs/cifs/ntlmssp.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) International Business Machines Corp., 2002,2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Author(s): Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define NTLMSSP_SIGNATURE "NTLMSSP"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* Message Types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define NtLmNegotiate cpu_to_le32(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define NtLmChallenge cpu_to_le32(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define NtLmAuthenticate cpu_to_le32(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define UnknownMessage cpu_to_le32(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* Negotiate Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define NTLMSSP_NEGOTIATE_UNICODE 0x01 /* Text strings are unicode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define NTLMSSP_NEGOTIATE_OEM 0x02 /* Text strings are in OEM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define NTLMSSP_REQUEST_TARGET 0x04 /* Srv returns its auth realm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* define reserved9 0x08 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define NTLMSSP_NEGOTIATE_SIGN 0x0010 /* Request signing capability */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define NTLMSSP_NEGOTIATE_SEAL 0x0020 /* Request confidentiality */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define NTLMSSP_NEGOTIATE_DGRAM 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define NTLMSSP_NEGOTIATE_LM_KEY 0x0080 /* Use LM session key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* defined reserved 8 0x0100 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define NTLMSSP_NEGOTIATE_NTLM 0x0200 /* NTLM authentication */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define NTLMSSP_NEGOTIATE_NT_ONLY 0x0400 /* Lanman not allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define NTLMSSP_ANONYMOUS 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x1000 /* reserved6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000 /* client/server same machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000 /* Sign. All security levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define NTLMSSP_TARGET_TYPE_SERVER 0x20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define NTLMSSP_TARGET_TYPE_SHARE 0x40000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define NTLMSSP_NEGOTIATE_EXTENDED_SEC 0x80000 /* NB:not related to NTLMv2 pwd*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* #define NTLMSSP_REQUEST_INIT_RESP 0x100000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define NTLMSSP_NEGOTIATE_IDENTIFY 0x100000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define NTLMSSP_REQUEST_ACCEPT_RESP 0x200000 /* reserved5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define NTLMSSP_REQUEST_NON_NT_KEY 0x400000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x800000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* #define reserved4 0x1000000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define NTLMSSP_NEGOTIATE_VERSION 0x2000000 /* we do not set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* #define reserved3 0x4000000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* #define reserved2 0x8000000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* #define reserved1 0x10000000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define NTLMSSP_NEGOTIATE_128 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define NTLMSSP_NEGOTIATE_56 0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* Define AV Pair Field IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) enum av_field_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) NTLMSSP_AV_EOL = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) NTLMSSP_AV_NB_COMPUTER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) NTLMSSP_AV_NB_DOMAIN_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) NTLMSSP_AV_DNS_COMPUTER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) NTLMSSP_AV_DNS_DOMAIN_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) NTLMSSP_AV_DNS_TREE_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) NTLMSSP_AV_FLAGS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) NTLMSSP_AV_TIMESTAMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) NTLMSSP_AV_RESTRICTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) NTLMSSP_AV_TARGET_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) NTLMSSP_AV_CHANNEL_BINDINGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* Although typedefs are not commonly used for structure definitions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* in the Linux kernel, in this particular case they are useful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* to more closely match the standards document for NTLMSSP from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /* OpenGroup and to make the code more closely match the standard in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* appearance */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) typedef struct _SECURITY_BUFFER {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) __le16 Length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) __le16 MaximumLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __le32 BufferOffset; /* offset to buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) } __attribute__((packed)) SECURITY_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) typedef struct _NEGOTIATE_MESSAGE {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) __le32 MessageType; /* NtLmNegotiate = 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __le32 NegotiateFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* SECURITY_BUFFER for version info not present since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) do not set the version is present flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) char DomainString[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* followed by WorkstationString */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) typedef struct _CHALLENGE_MESSAGE {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) __le32 MessageType; /* NtLmChallenge = 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) SECURITY_BUFFER TargetName;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __le32 NegotiateFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) __u8 Challenge[CIFS_CRYPTO_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) __u8 Reserved[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) SECURITY_BUFFER TargetInfoArray;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* SECURITY_BUFFER for version info not present since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) do not set the version is present flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) typedef struct _AUTHENTICATE_MESSAGE {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __le32 MessageType; /* NtLmsAuthenticate = 3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) SECURITY_BUFFER LmChallengeResponse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) SECURITY_BUFFER NtChallengeResponse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) SECURITY_BUFFER DomainName;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) SECURITY_BUFFER UserName;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) SECURITY_BUFFER WorkstationName;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) SECURITY_BUFFER SessionKey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) __le32 NegotiateFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* SECURITY_BUFFER for version info not present since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) do not set the version is present flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) char UserString[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * Size of the session key (crypto key encrypted with the password
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct cifs_ses *ses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) const struct nls_table *nls_cp);