Squid Web Cache master
Loading...
Searching...
No Matches
ntlmauth.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_LIB_NTLMAUTH_NTLMAUTH_H
10#define SQUID_LIB_NTLMAUTH_NTLMAUTH_H
11
12/* NP: All of this cruft is little endian */
13/* Endian functions are usually handled by the OS but not always. */
15
16/* Used internally. Microsoft seems to think this is right, I believe them.
17 * Right. */
18#define NTLM_MAX_FIELD_LENGTH 300 /* max length of an NTLMSSP field */
19
20/* max length of the BLOB data. (and helper input/output buffer) */
21#define NTLM_BLOB_BUFFER_SIZE 10240
22
23/* Here start the NTLMSSP definitions */
24
25/* these are marked as "extra" fields */
26#define NTLM_REQUEST_INIT_RESPONSE 0x100000
27#define NTLM_REQUEST_ACCEPT_RESPONSE 0x200000
28#define NTLM_REQUEST_NON_NT_SESSION_KEY 0x400000
29
30/* NTLM error codes */
46
48typedef struct _strhdr {
49 int16_t len;
50 int16_t maxlen;
51 int32_t offset;
53
55typedef struct _lstring {
56 int32_t l;
57 char *str;
59
61void ntlm_dump_ntlmssp_flags(const uint32_t flags);
62
63/* ************************************************************************* */
64/* Packet and Payload structures and handling functions */
65/* ************************************************************************* */
66
67/* NTLM request types that we know about */
68#define NTLM_ANY 0
69#define NTLM_NEGOTIATE 1
70#define NTLM_CHALLENGE 2
71#define NTLM_AUTHENTICATE 3
72
76typedef struct _ntlmhdr {
77 char signature[8];
78 int32_t type;
80
82NtlmError ntlm_validate_packet(const ntlmhdr *packet, const int32_t type);
83
86 const int32_t packet_length,
87 const strhdr *str,
88 const uint32_t flags);
89
91void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
92 char *payload,
93 int *payload_length,
94 strhdr * hdr,
95 const char *toadd,
96 const uint16_t toadd_length);
97
98/* ************************************************************************* */
99/* Negotiate Packet structures and functions */
100/* ************************************************************************* */
101
102/* negotiate request flags */
103#define NTLM_NEGOTIATE_UNICODE 0x0001
104#define NTLM_NEGOTIATE_ASCII 0x0002
105#define NTLM_NEGOTIATE_REQUEST_TARGET 0x0004
106#define NTLM_NEGOTIATE_REQUEST_SIGN 0x0010
107#define NTLM_NEGOTIATE_REQUEST_SEAL 0x0020
108#define NTLM_NEGOTIATE_DATAGRAM_STYLE 0x0040
109#define NTLM_NEGOTIATE_USE_LM 0x0080
110#define NTLM_NEGOTIATE_USE_NETWARE 0x0100
111#define NTLM_NEGOTIATE_USE_NTLM 0x0200
112#define NTLM_NEGOTIATE_DOMAIN_SUPPLIED 0x1000
113#define NTLM_NEGOTIATE_WORKSTATION_SUPPLIED 0x2000
114#define NTLM_NEGOTIATE_THIS_IS_LOCAL_CALL 0x4000
115#define NTLM_NEGOTIATE_ALWAYS_SIGN 0x8000
116
125
126/* ************************************************************************* */
127/* Challenge Packet structures and functions */
128/* ************************************************************************* */
129
130#define NTLM_NONCE_LEN 8
131
132/* challenge request flags */
133#define NTLM_CHALLENGE_TARGET_IS_DOMAIN 0x10000
134#define NTLM_CHALLENGE_TARGET_IS_SERVER 0x20000
135#define NTLM_CHALLENGE_TARGET_IS_SHARE 0x40000
136
147
148/* Size of the ntlm_challenge structures formatted fields (excluding payload) */
149#define NTLM_CHALLENGE_HEADER_OFFSET (sizeof(ntlm_challenge)-256)
150
152void ntlm_make_nonce(char *nonce);
153
158 const char *domain,
159 const char *domain_controller,
160 const char *challenge_nonce,
161 const int challenge_nonce_len,
162 const uint32_t flags);
163
164/* ************************************************************************* */
165/* Authenticate Packet structures and functions */
166/* ************************************************************************* */
167
180
183 char *user,
184 char *domain,
185 const int32_t size);
186
187#endif /* SQUID_LIB_NTLMAUTH_NTLMAUTH_H */
188
int size
Definition ModDevPoll.cc:70
NtlmError ntlm_unpack_auth(const ntlm_authenticate *auth, char *user, char *domain, const int32_t size)
Definition ntlmauth.cc:247
struct _ntlm_authenticate ntlm_authenticate
struct _ntlm_challenge ntlm_challenge
struct _strhdr strhdr
void ntlm_make_challenge(ntlm_challenge *ch, const char *domain, const char *domain_controller, const char *challenge_nonce, const int challenge_nonce_len, const uint32_t flags)
Definition ntlmauth.cc:210
NtlmError
Definition ntlmauth.h:32
lstring ntlm_fetch_string(const ntlmhdr *packet, const int32_t packet_length, const strhdr *str, const uint32_t flags)
Definition ntlmauth.cc:98
void ntlm_dump_ntlmssp_flags(const uint32_t flags)
Definition ntlmauth.cc:30
struct _lstring lstring
#define NTLM_NONCE_LEN
Definition ntlmauth.h:130
struct _ntlmhdr ntlmhdr
struct _ntlm_negotiate ntlm_negotiate
void ntlm_add_to_payload(const ntlmhdr *packet_hdr, char *payload, int *payload_length, strhdr *hdr, const char *toadd, const uint16_t toadd_length)
Definition ntlmauth.cc:165
void ntlm_make_nonce(char *nonce)
Definition ntlmauth.cc:196
NtlmError ntlm_validate_packet(const ntlmhdr *packet, const int32_t type)
Definition ntlmauth.cc:67
char * str
Definition ntlmauth.h:57
int32_t l
Definition ntlmauth.h:56
char payload[256 *6]
Definition ntlmauth.h:178
u_char challenge[NTLM_NONCE_LEN]
Definition ntlmauth.h:142
uint32_t context_high
Definition ntlmauth.h:144
uint32_t flags
Definition ntlmauth.h:141
char payload[256]
Definition ntlmauth.h:145
uint32_t context_low
Definition ntlmauth.h:143
strhdr workstation
Definition ntlmauth.h:122
char payload[256]
Definition ntlmauth.h:123
uint32_t flags
Definition ntlmauth.h:120
int32_t type
Definition ntlmauth.h:78
char signature[8]
Definition ntlmauth.h:77
int16_t maxlen
Definition ntlmauth.h:50
int32_t offset
Definition ntlmauth.h:51
int16_t len
Definition ntlmauth.h:49