0001
0002
0003
0004
0005
0006
0007
0008
0009 #define NTLMSSP_SIGNATURE "NTLMSSP"
0010
0011 #define NtLmNegotiate cpu_to_le32(1)
0012 #define NtLmChallenge cpu_to_le32(2)
0013 #define NtLmAuthenticate cpu_to_le32(3)
0014 #define UnknownMessage cpu_to_le32(8)
0015
0016
0017 #define NTLMSSP_NEGOTIATE_UNICODE 0x01
0018 #define NTLMSSP_NEGOTIATE_OEM 0x02
0019 #define NTLMSSP_REQUEST_TARGET 0x04
0020
0021 #define NTLMSSP_NEGOTIATE_SIGN 0x0010
0022 #define NTLMSSP_NEGOTIATE_SEAL 0x0020
0023 #define NTLMSSP_NEGOTIATE_DGRAM 0x0040
0024 #define NTLMSSP_NEGOTIATE_LM_KEY 0x0080
0025
0026 #define NTLMSSP_NEGOTIATE_NTLM 0x0200
0027 #define NTLMSSP_NEGOTIATE_NT_ONLY 0x0400
0028 #define NTLMSSP_ANONYMOUS 0x0800
0029 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x1000
0030 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000
0031 #define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000
0032 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000
0033 #define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000
0034 #define NTLMSSP_TARGET_TYPE_SERVER 0x20000
0035 #define NTLMSSP_TARGET_TYPE_SHARE 0x40000
0036 #define NTLMSSP_NEGOTIATE_EXTENDED_SEC 0x80000
0037
0038 #define NTLMSSP_NEGOTIATE_IDENTIFY 0x100000
0039 #define NTLMSSP_REQUEST_ACCEPT_RESP 0x200000
0040 #define NTLMSSP_REQUEST_NON_NT_KEY 0x400000
0041 #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x800000
0042
0043 #define NTLMSSP_NEGOTIATE_VERSION 0x2000000
0044
0045
0046
0047 #define NTLMSSP_NEGOTIATE_128 0x20000000
0048 #define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000
0049 #define NTLMSSP_NEGOTIATE_56 0x80000000
0050
0051
0052 enum av_field_type {
0053 NTLMSSP_AV_EOL = 0,
0054 NTLMSSP_AV_NB_COMPUTER_NAME,
0055 NTLMSSP_AV_NB_DOMAIN_NAME,
0056 NTLMSSP_AV_DNS_COMPUTER_NAME,
0057 NTLMSSP_AV_DNS_DOMAIN_NAME,
0058 NTLMSSP_AV_DNS_TREE_NAME,
0059 NTLMSSP_AV_FLAGS,
0060 NTLMSSP_AV_TIMESTAMP,
0061 NTLMSSP_AV_RESTRICTION,
0062 NTLMSSP_AV_TARGET_NAME,
0063 NTLMSSP_AV_CHANNEL_BINDINGS
0064 };
0065
0066
0067
0068
0069
0070
0071
0072 typedef struct _SECURITY_BUFFER {
0073 __le16 Length;
0074 __le16 MaximumLength;
0075 __le32 BufferOffset;
0076 } __attribute__((packed)) SECURITY_BUFFER;
0077
0078 typedef struct _NEGOTIATE_MESSAGE {
0079 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
0080 __le32 MessageType;
0081 __le32 NegotiateFlags;
0082 SECURITY_BUFFER DomainName;
0083 SECURITY_BUFFER WorkstationName;
0084
0085
0086 char DomainString[0];
0087
0088 } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
0089
0090 #define NTLMSSP_REVISION_W2K3 0x0F
0091
0092
0093 struct ntlmssp_version {
0094 __u8 ProductMajorVersion;
0095 __u8 ProductMinorVersion;
0096 __le16 ProductBuild;
0097 __u8 Reserved[3];
0098 __u8 NTLMRevisionCurrent;
0099 } __packed;
0100
0101
0102 struct negotiate_message {
0103 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
0104 __le32 MessageType;
0105 __le32 NegotiateFlags;
0106 SECURITY_BUFFER DomainName;
0107 SECURITY_BUFFER WorkstationName;
0108 struct ntlmssp_version Version;
0109
0110 char DomainString[];
0111
0112 } __packed;
0113
0114 typedef struct _CHALLENGE_MESSAGE {
0115 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
0116 __le32 MessageType;
0117 SECURITY_BUFFER TargetName;
0118 __le32 NegotiateFlags;
0119 __u8 Challenge[CIFS_CRYPTO_KEY_SIZE];
0120 __u8 Reserved[8];
0121 SECURITY_BUFFER TargetInfoArray;
0122
0123
0124 } __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE;
0125
0126 typedef struct _AUTHENTICATE_MESSAGE {
0127 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
0128 __le32 MessageType;
0129 SECURITY_BUFFER LmChallengeResponse;
0130 SECURITY_BUFFER NtChallengeResponse;
0131 SECURITY_BUFFER DomainName;
0132 SECURITY_BUFFER UserName;
0133 SECURITY_BUFFER WorkstationName;
0134 SECURITY_BUFFER SessionKey;
0135 __le32 NegotiateFlags;
0136
0137
0138 char UserString[0];
0139 } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
0140
0141
0142
0143
0144
0145 int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
0146 int build_ntlmssp_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
0147 struct cifs_ses *ses,
0148 struct TCP_Server_Info *server,
0149 const struct nls_table *nls_cp);
0150 int build_ntlmssp_smb3_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
0151 struct cifs_ses *ses,
0152 struct TCP_Server_Info *server,
0153 const struct nls_table *nls_cp);
0154 int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
0155 struct cifs_ses *ses,
0156 struct TCP_Server_Info *server,
0157 const struct nls_table *nls_cp);