78#define DATA(...) { __VA_ARGS__ }
81#define KEY_TEST( name, DOMAIN, USERNAME, PASSWORD, EXPECTED ) \
82 static struct ntlm_key_test name = { \
84 .username = USERNAME, \
85 .password = PASSWORD, \
92#define AUTHENTICATE_TEST( name, DOMAIN, USERNAME, PASSWORD, \
93 WORKSTATION, NONCE, CHALLENGE, EXPECTED ) \
94 static const uint8_t name ## _challenge[] = CHALLENGE; \
95 static const uint8_t name ## _expected[] = EXPECTED; \
96 static struct ntlm_authenticate_test name = { \
98 .username = USERNAME, \
99 .password = PASSWORD, \
100 .workstation = WORKSTATION, \
104 .challenge = ( ( void * ) name ## _challenge ), \
105 .challenge_len = sizeof ( name ## _challenge ), \
106 .expected = ( ( void * ) name ## _expected ), \
107 .expected_len = sizeof ( name ## _expected ), \
111KEY_TEST ( msnlmp_ntowfv2,
"Domain",
"User",
"Password",
112 DATA ( 0x0c, 0x86, 0x8a, 0x40, 0x3b, 0xfd, 0x7a, 0x93, 0xa3, 0x00,
113 0x1e, 0xf2, 0x2e, 0xf0, 0x2e, 0x3f ) );
117 "Domain",
"User",
"Password",
"COMPUTER",
118 DATA ( 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa ),
119 DATA ( 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00,
120 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x38, 0x00, 0x00, 0x00,
121 0x33, 0x82, 0x8a, 0xe2, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
122 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
123 0x24, 0x00, 0x24, 0x00, 0x44, 0x00, 0x00, 0x00, 0x06, 0x00,
124 0x70, 0x17, 0x00, 0x00, 0x00, 0x0f, 0x53, 0x00, 0x65, 0x00,
125 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x02, 0x00,
126 0x0c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00,
127 0x69, 0x00, 0x6e, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x53, 0x00,
128 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00,
129 0x00, 0x00, 0x00, 0x00 ),
130 DATA ( 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x03, 0x00,
131 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x6c, 0x00, 0x00, 0x00,
132 0x54, 0x00, 0x54, 0x00, 0x84, 0x00, 0x00, 0x00, 0x0c, 0x00,
133 0x0c, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00,
134 0x54, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x5c, 0x00,
135 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0xd8, 0x00, 0x00, 0x00,
136 0x35, 0x82, 0x88, 0xe2, 0x05, 0x01, 0x28, 0x0a, 0x00, 0x00,
137 0x00, 0x0f, 0x44, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00,
138 0x69, 0x00, 0x6e, 0x00, 0x55, 0x00, 0x73, 0x00, 0x65, 0x00,
139 0x72, 0x00, 0x43, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x50, 0x00,
140 0x55, 0x00, 0x54, 0x00, 0x45, 0x00, 0x52, 0x00, 0x86, 0xc3,
141 0x50, 0x97, 0xac, 0x9c, 0xec, 0x10, 0x25, 0x54, 0x76, 0x4a,
142 0x57, 0xcc, 0xcc, 0x19, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
143 0xaa, 0xaa, 0x68, 0xcd, 0x0a, 0xb8, 0x51, 0xe5, 0x1c, 0x96,
144 0xaa, 0xbc, 0x92, 0x7b, 0xeb, 0xef, 0x6a, 0x1c, 0x01, 0x01,
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
147 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0c, 0x00,
148 0x44, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00,
149 0x6e, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x53, 0x00, 0x65, 0x00,
150 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc5, 0xda, 0xd2, 0x54,
152 0x4f, 0xc9, 0x79, 0x90, 0x94, 0xce, 0x1c, 0xe9, 0x0b, 0xc9,
163 const char *file,
unsigned int line ) {
170#define ntlm_key_ok( test ) \
171 ntlm_key_okx ( test, __FILE__, __LINE__ )
189 const char *field,
const char *file,
190 unsigned int line ) {
205 expected_raw = ( ( (
void * ) expected ) +
207 DBGC (
msg,
"NTLM %s expected:\n", field );
209 DBGC (
msg,
"NTLM %s actual:\n", field );
211 okx (
data->len == expected_data->
len, file, line );
214#define ntlm_data_ok( msg, msg_len, data, expected, expected_data ) \
215 ntlm_data_okx ( msg, msg_len, data, expected, expected_data, \
226 const char *file,
unsigned int line ) {
237 &
info ) == 0, file, line );
248 okx (
len >=
sizeof ( *auth ), file, line );
250 okx ( auth !=
NULL, file, line );
254 test->workstation, &lm, &
nt, auth ) ==
len,
259 sizeof ( auth->
header ) ) == 0, file, line );
263 &expected->
lm,
"LM", file, line );
267 &expected->
nt,
"NT", file, line );
271 &expected->
domain,
"domain", file, line );
275 &expected->
user,
"user", file, line );
280 "workstation",file, line );
286 "session", file, line );
292#define ntlm_authenticate_ok( test ) \
293 ntlm_authenticate_okx ( test, __FILE__, __LINE__ )
#define NULL
NULL pointer (VOID *)
union @162305117151260234136356364136041353210355154177 key
Sense key.
#define DATA(...)
Define inline data.
uint16_t offset
Offset to command line.
uint8_t data[48]
Additional event data.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define le16_to_cpu(value)
#define le32_to_cpu(value)
void * malloc(size_t size)
Allocate memory.
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
struct mschapv2_nt_response nt
NT response.
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.
size_t ntlm_authenticate_len(struct ntlm_challenge_info *info, const char *domain, const char *username, const char *workstation)
Calculate NTLM Authenticate message length.
void ntlm_key(const char *domain, const char *username, const char *password, struct ntlm_key *key)
Calculate NTLM verification key.
NT LAN Manager (NTLM) authentication.
@ NTLM_NEGOTIATE_KEY_EXCH
Negotiate key exchange.
#define AUTHENTICATE_TEST(name, DOMAIN, USERNAME, PASSWORD, WORKSTATION, NONCE, CHALLENGE, EXPECTED)
Define an authentication test.
static void ntlm_data_okx(struct ntlm_header *msg, size_t msg_len, struct ntlm_data *data, struct ntlm_header *expected, struct ntlm_data *expected_data, const char *field, const char *file, unsigned int line)
Report NTLM variable-length data test result.
static void ntlm_test_exec(void)
Perform NTLM self-test.
#define KEY_TEST(name, DOMAIN, USERNAME, PASSWORD, EXPECTED)
Define a key generation digest test.
static void ntlm_key_okx(struct ntlm_key_test *test, const char *file, unsigned int line)
Report key generation test result.
static void ntlm_authenticate_okx(struct ntlm_authenticate_test *test, const char *file, unsigned int line)
Report NTLM authentication test result.
#define ntlm_authenticate_ok(test)
#define ntlm_key_ok(test)
static void(* free)(struct refcnt *refcnt))
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
struct ntlm_authenticate * expected
Expected Authenticate message.
const char * password
Password (or NULL)
const char * workstation
Workstation (or NULL)
struct ntlm_nonce nonce
Nonce.
size_t challenge_len
Length of Challenge message.
size_t expected_len
Expected length of Authenticate message.
struct ntlm_challenge * challenge
Challenge message.
const char * username
User name (or NULL)
const char * domain
Domain name (or NULL)
struct ntlm_data lm
LAN Manager response.
struct ntlm_data user
User name.
struct ntlm_data domain
Domain name.
struct ntlm_data nt
NT response.
struct ntlm_data session
Session key.
struct ntlm_header header
Message header.
struct ntlm_data workstation
Workstation name.
uint32_t flags
Negotiation flags.
NTLM challenge information.
A variable-length data descriptor.
uint16_t len
Length (in bytes)
uint32_t offset
Offset from start of message header.
const char * password
Password (or NULL)
const char * username
User name (or NULL)
struct ntlm_key expected
Expected key.
const char * domain
Domain name (or NULL)
An NTLM verification key.
Self-test infrastructure.
#define okx(success, file, line)
Report test result.
#define __self_test
Declare a self-test.