iPXE
ntlm.h
Go to the documentation of this file.
1#ifndef _IPXE_NTLM_H
2#define _IPXE_NTLM_H
3
4/** @file
5 *
6 * NT LAN Manager (NTLM) authentication
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/crypto.h>
15#include <ipxe/md5.h>
16
17/** A message header */
19 /** Magic signature */
21 /** Message type */
23} __attribute__ (( packed ));
24
25/** Magic signature */
26#define NTLM_MAGIC { 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0' }
27
28/** Message types */
30 /** Negotiate message type */
31 NTLM_NEGOTIATE = 0x00000001UL,
32 /** Challenge message type */
33 NTLM_CHALLENGE = 0x00000002UL,
34 /** Authenticate message */
35 NTLM_AUTHENTICATE = 0x00000003UL,
36};
37
38/** Negotiation flags */
40 /** Negotiate key exchange */
42 /** Negotiate extended security */
44 /** Negotiate always sign */
46 /** Negotiate NTLM key */
47 NTLM_NEGOTIATE_NTLM = 0x00000200UL,
48 /** Request target name and information */
49 NTLM_REQUEST_TARGET = 0x00000004UL,
50 /** Negotiate Unicode character encoding */
51 NTLM_NEGOTIATE_UNICODE = 0x00000001UL,
52};
53
54/** A version descriptor */
56 /** Product major version */
58 /** Product minor version */
60 /** Product build number */
62 /** Reserved */
64 /** NTLMSSP revision */
66} __attribute__ (( packed ));
67
68/** A nonce */
69struct ntlm_nonce {
70 /** Raw bytes */
72} __attribute__ (( packed ));
73
74/** A variable-length data descriptor */
75struct ntlm_data {
76 /** Length (in bytes) */
78 /** Maximum length (in bytes)
79 *
80 * Should always be set equal to the length; this field is
81 * entirely superfluous.
82 */
84 /** Offset from start of message header */
86} __attribute__ (( packed ));
87
88/** A Negotiate message */
90 /** Message header */
92 /** Negotiation flags */
94 /** Domain name */
96 /** Workstation name */
98} __attribute__ (( packed ));
99
100/** A Challenge message */
102 /** Message header */
104 /** Target name */
106 /** Negotiation flags */
108 /** Server nonce */
110 /** Reserved */
112 /** Target information */
114} __attribute__ (( packed ));
115
116/** An Authenticate message */
118 /** Message header */
120 /** LAN Manager response */
121 struct ntlm_data lm;
122 /** NT response */
123 struct ntlm_data nt;
124 /** Domain name */
126 /** User name */
128 /** Workstation name */
130 /** Session key */
132 /** Negotiation flags */
134} __attribute__ (( packed ));
135
136/** A LAN Manager response */
138 /** HMAC-MD5 digest */
140 /** Client nonce */
142} __attribute__ (( packed ));
143
144/** An NT response */
146 /** HMAC-MD5 digest */
148 /** Response version */
150 /** Highest response version */
152 /** Reserved */
154 /** Current time */
156 /** Client nonce */
158 /** Must be zero */
160} __attribute__ (( packed ));
161
162/** NTLM version */
163#define NTLM_VERSION_NTLMV2 0x01
164
165/** NTLM challenge information */
167 /** Server nonce */
169 /** Target information */
170 void *target;
171 /** Length of target information */
172 size_t len;
173};
174
175/** An NTLM verification key */
176struct ntlm_key {
177 /** Raw bytes */
179};
180
181extern const struct ntlm_negotiate ntlm_negotiate;
182extern int ntlm_challenge ( struct ntlm_challenge *challenge, size_t len,
183 struct ntlm_challenge_info *info );
184extern void ntlm_key ( const char *domain, const char *username,
185 const char *password, struct ntlm_key *key );
186extern void ntlm_response ( struct ntlm_challenge_info *info,
187 struct ntlm_key *key, struct ntlm_nonce *nonce,
188 struct ntlm_lm_response *lm,
189 struct ntlm_nt_response *nt );
190extern size_t ntlm_authenticate ( struct ntlm_challenge_info *info,
191 const char *domain, const char *username,
192 const char *workstation,
193 struct ntlm_lm_response *lm,
194 struct ntlm_nt_response *nt,
195 struct ntlm_authenticate *auth );
196extern size_t ntlm_authenticate_len ( struct ntlm_challenge_info *info,
197 const char *domain, const char *username,
198 const char *workstation );
199
200#endif /* _IPXE_NTLM_H */
union @162305117151260234136356364136041353210355154177 key
Sense key.
Definition scsi.h:3
u32 info
Definition ar9003_mac.h:0
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
ring len
Length.
Definition dwmac.h:226
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Cryptographic API.
static struct dynamic_item username
Definition login_ui.c:36
static struct dynamic_item password
Definition login_ui.c:37
MD5 algorithm.
#define MD5_DIGEST_SIZE
MD5 digest size.
Definition md5.h:73
struct mschapv2_nt_response nt
NT response.
Definition mschapv2.h:5
void ntlm_response(struct ntlm_challenge_info *info, struct ntlm_key *key, struct ntlm_nonce *nonce, struct ntlm_lm_response *lm, struct ntlm_nt_response *nt)
Construct NTLM responses.
Definition ntlm.c:167
ntlm_flags
Negotiation flags.
Definition ntlm.h:39
@ NTLM_NEGOTIATE_NTLM
Negotiate NTLM key.
Definition ntlm.h:47
@ NTLM_REQUEST_TARGET
Request target name and information.
Definition ntlm.h:49
@ NTLM_NEGOTIATE_KEY_EXCH
Negotiate key exchange.
Definition ntlm.h:41
@ NTLM_NEGOTIATE_UNICODE
Negotiate Unicode character encoding.
Definition ntlm.h:51
@ NTLM_NEGOTIATE_ALWAYS_SIGN
Negotiate always sign.
Definition ntlm.h:45
@ NTLM_NEGOTIATE_EXTENDED_SESSIONSECURITY
Negotiate extended security.
Definition ntlm.h:43
size_t ntlm_authenticate(struct ntlm_challenge_info *info, const char *domain, const char *username, const char *workstation, struct ntlm_lm_response *lm, struct ntlm_nt_response *nt, struct ntlm_authenticate *auth)
Construct NTLM Authenticate message.
Definition ntlm.c:267
int ntlm_challenge(struct ntlm_challenge *challenge, size_t len, struct ntlm_challenge_info *info)
Parse NTLM Challenge.
Definition ntlm.c:69
ntlm_type
Message types.
Definition ntlm.h:29
@ NTLM_AUTHENTICATE
Authenticate message.
Definition ntlm.h:35
@ NTLM_CHALLENGE
Challenge message type.
Definition ntlm.h:33
@ NTLM_NEGOTIATE
Negotiate message type.
Definition ntlm.h:31
size_t ntlm_authenticate_len(struct ntlm_challenge_info *info, const char *domain, const char *username, const char *workstation)
Calculate NTLM Authenticate message length.
Definition ntlm.c:326
void ntlm_key(const char *domain, const char *username, const char *password, struct ntlm_key *key)
Calculate NTLM verification key.
Definition ntlm.c:115
An Authenticate message.
Definition ntlm.h:117
struct ntlm_data lm
LAN Manager response.
Definition ntlm.h:121
struct ntlm_data user
User name.
Definition ntlm.h:127
struct ntlm_data domain
Domain name.
Definition ntlm.h:125
struct ntlm_data nt
NT response.
Definition ntlm.h:123
struct ntlm_data session
Session key.
Definition ntlm.h:131
struct ntlm_header header
Message header.
Definition ntlm.h:119
struct ntlm_data workstation
Workstation name.
Definition ntlm.h:129
uint32_t flags
Negotiation flags.
Definition ntlm.h:133
NTLM challenge information.
Definition ntlm.h:166
void * target
Target information.
Definition ntlm.h:170
struct ntlm_nonce * nonce
Server nonce.
Definition ntlm.h:168
size_t len
Length of target information.
Definition ntlm.h:172
A Challenge message.
Definition ntlm.h:101
uint32_t flags
Negotiation flags.
Definition ntlm.h:107
struct ntlm_nonce nonce
Server nonce.
Definition ntlm.h:109
struct ntlm_header header
Message header.
Definition ntlm.h:103
struct ntlm_data info
Target information.
Definition ntlm.h:113
struct ntlm_data name
Target name.
Definition ntlm.h:105
uint8_t reserved[8]
Reserved.
Definition ntlm.h:111
A variable-length data descriptor.
Definition ntlm.h:75
uint16_t len
Length (in bytes)
Definition ntlm.h:77
uint32_t offset
Offset from start of message header.
Definition ntlm.h:85
uint16_t max_len
Maximum length (in bytes)
Definition ntlm.h:83
A message header.
Definition ntlm.h:18
uint32_t type
Message type.
Definition ntlm.h:22
uint8_t magic[8]
Magic signature.
Definition ntlm.h:20
An NTLM verification key.
Definition ntlm.h:176
uint8_t raw[MD5_DIGEST_SIZE]
Raw bytes.
Definition ntlm.h:178
A LAN Manager response.
Definition ntlm.h:137
uint8_t digest[MD5_DIGEST_SIZE]
HMAC-MD5 digest.
Definition ntlm.h:139
struct ntlm_nonce nonce
Client nonce.
Definition ntlm.h:141
A Negotiate message.
Definition ntlm.h:89
uint32_t flags
Negotiation flags.
Definition ntlm.h:93
struct ntlm_data domain
Domain name.
Definition ntlm.h:95
struct ntlm_data workstation
Workstation name.
Definition ntlm.h:97
struct ntlm_header header
Message header.
Definition ntlm.h:91
A nonce.
Definition ntlm.h:69
uint8_t raw[8]
Raw bytes.
Definition ntlm.h:71
An NT response.
Definition ntlm.h:145
uint64_t time
Current time.
Definition ntlm.h:155
struct ntlm_nonce nonce
Client nonce.
Definition ntlm.h:157
uint32_t zero
Must be zero.
Definition ntlm.h:159
uint8_t version
Response version.
Definition ntlm.h:149
uint8_t digest[MD5_DIGEST_SIZE]
HMAC-MD5 digest.
Definition ntlm.h:147
uint8_t reserved_a[6]
Reserved.
Definition ntlm.h:153
uint8_t high
Highest response version.
Definition ntlm.h:151
A version descriptor.
Definition ntlm.h:55
uint8_t revision
NTLMSSP revision.
Definition ntlm.h:65
uint8_t minor
Product minor version.
Definition ntlm.h:59
uint16_t build
Product build number.
Definition ntlm.h:61
uint8_t reserved[3]
Reserved.
Definition ntlm.h:63
uint8_t major
Product major version.
Definition ntlm.h:57
u8 nonce[32]
Nonce value.
Definition wpa.h:25