iPXE
|
NT LAN Manager (NTLM) authentication. More...
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/md4.h>
#include <ipxe/md5.h>
#include <ipxe/hmac.h>
#include <ipxe/ntlm.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
int | ntlm_challenge (struct ntlm_challenge *challenge, size_t len, struct ntlm_challenge_info *info) |
Parse NTLM Challenge. More... | |
void | ntlm_key (const char *domain, const char *username, const char *password, struct ntlm_key *key) |
Calculate NTLM verification key. More... | |
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. More... | |
static void * | ntlm_append (struct ntlm_header *header, struct ntlm_data *data, void *payload, size_t len) |
Append data to NTLM message. More... | |
static void * | ntlm_append_string (struct ntlm_header *header, struct ntlm_data *data, void *payload, const char *string) |
Append Unicode string data to NTLM message. More... | |
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. More... | |
size_t | ntlm_authenticate_len (struct ntlm_challenge_info *info, const char *domain, const char *username, const char *workstation) |
Calculate NTLM Authenticate message length. More... | |
Variables | |
const struct ntlm_negotiate | ntlm_negotiate |
Negotiate message. More... | |
NT LAN Manager (NTLM) authentication.
Definition in file ntlm.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
int ntlm_challenge | ( | struct ntlm_challenge * | challenge, |
size_t | len, | ||
struct ntlm_challenge_info * | info | ||
) |
Parse NTLM Challenge.
challenge | Challenge message |
len | Length of Challenge message |
info | Challenge information to fill in |
rc | Return status code |
Definition at line 68 of file ntlm.c.
References DBGC, DBGC_HDA, EINVAL, info, ntlm_challenge::info, le16_to_cpu, le32_to_cpu, len, ntlm_data::len, ntlm_challenge::nonce, offset, and ntlm_data::offset.
void ntlm_key | ( | const char * | domain, |
const char * | username, | ||
const char * | password, | ||
struct ntlm_key * | key | ||
) |
Calculate NTLM verification key.
domain | Domain name (or NULL) |
username | User name (or NULL) |
password | Password (or NULL) |
key | Key to fill in |
This is the NTOWFv2() function as defined in MS-NLMP.
Definition at line 114 of file ntlm.c.
References c, cpu_to_le16, ctx, DBGC, DBGC_HDA, digest_final(), digest_init(), digest_update(), hmac_final(), hmac_init(), hmac_update(), key, md4_algorithm, MD4_CTX_SIZE, MD4_DIGEST_SIZE, md5_algorithm, MD5_BLOCK_SIZE, MD5_CTX_SIZE, password, toupper(), username, and wc.
Referenced by http_ntlm_authenticate(), ntlm_authenticate_okx(), and ntlm_key_okx().
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.
info | Challenge information |
key | Verification key |
nonce | Nonce, or NULL to use a random nonce |
lm | LAN Manager response to fill in |
nt | NT response to fill in |
Definition at line 166 of file ntlm.c.
References ctx, DBGC, DBGC_HDA, ntlm_lm_response::digest, hmac_final(), hmac_init(), hmac_update(), info, key, md5_algorithm, MD5_BLOCK_SIZE, MD5_CTX_SIZE, memcpy(), memset(), nonce, ntlm_lm_response::nonce, nt, NTLM_VERSION_NTLMV2, offsetof, random(), ntlm_nonce::raw, typeof(), and version.
Referenced by http_ntlm_authenticate(), and ntlm_authenticate_okx().
|
static |
Append data to NTLM message.
header | Message header, or NULL to only calculate next payload |
data | Data descriptor |
payload | Data payload |
len | Length of data |
payload | Next data payload |
Definition at line 216 of file ntlm.c.
References cpu_to_le16, cpu_to_le32, data, header, and len.
Referenced by ntlm_append_string(), and ntlm_authenticate().
|
static |
Append Unicode string data to NTLM message.
header | Message header, or NULL to only calculate next payload |
data | Data descriptor |
payload | Data payload |
string | String to append, or NULL |
payload | Next data payload |
Definition at line 237 of file ntlm.c.
References c, cpu_to_le16, data, header, ntlm_append(), and tmp.
Referenced by ntlm_authenticate().
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.
info | Challenge information |
domain | Domain name, or NULL |
username | User name, or NULL |
workstation | Workstation name, or NULL |
lm | LAN Manager response |
nt | NT response |
auth | Message to fill in, or NULL to only calculate length |
len | Length of message |
Definition at line 266 of file ntlm.c.
References cpu_to_le32, DBGC, DBGC_HDA, ntlm_authenticate::domain, ntlm_negotiate::flags, ntlm_authenticate::flags, ntlm_negotiate::header, ntlm_authenticate::header, info, len, ntlm_authenticate::lm, ntlm_header::magic, memcpy(), memset(), nt, ntlm_authenticate::nt, ntlm_append(), ntlm_append_string(), NTLM_AUTHENTICATE, tmp, ntlm_header::type, ntlm_authenticate::user, username, and ntlm_authenticate::workstation.
Referenced by http_format_ntlm_auth(), and ntlm_authenticate_len().
size_t ntlm_authenticate_len | ( | struct ntlm_challenge_info * | info, |
const char * | domain, | ||
const char * | username, | ||
const char * | workstation | ||
) |
Calculate NTLM Authenticate message length.
info | Challenge information |
domain | Domain name, or NULL |
username | User name, or NULL |
workstation | Workstation name, or NULL |
len | Length of Authenticate message |
Definition at line 325 of file ntlm.c.
References info, ntlm_authenticate(), NULL, and username.
Referenced by http_ntlm_authenticate(), and ntlm_authenticate_okx().
const struct ntlm_negotiate ntlm_negotiate |
Negotiate message.
This message content is fixed since there is no need to specify the calling workstation name or domain name, and the set of flags is mandated by the MS-NLMP specification.