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 ), \ 111 KEY_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 );
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__ ) A variable-length data descriptor.
static void ntlm_authenticate_okx(struct ntlm_authenticate_test *test, const char *file, unsigned int line)
Report NTLM authentication test result.
struct ntlm_data lm
LAN Manager response.
#define le32_to_cpu(value)
const char * workstation
Workstation (or NULL)
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 expected_len
Expected length of Authenticate message.
#define DATA(...)
Define inline message data.
Self-test infrastructure.
const char * name
Test set name.
struct ntlm_nonce nonce
Nonce.
const char * domain
Domain name (or NULL)
struct ntlm_header header
Message header.
uint16_t len
Length (in bytes)
const char * username
User name (or NULL)
size_t challenge_len
Length of Challenge message.
struct ntlm_data nt
NT response.
#define okx(success, file, line)
Report test result.
const char * password
Password (or NULL)
static userptr_t size_t offset
Offset of the first segment within the content.
An NTLM verification key.
struct ntlm_key expected
Expected key.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct ntlm_data workstation
Workstation name.
const char * domain
Domain name (or NULL)
static void(* free)(struct refcnt *refcnt))
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.
struct ntlm_data domain
Domain name.
struct ntlm_data lm
LAN Manager response.
const char * username
User name (or NULL)
struct ntlm_data session
Session key.
struct ntlm_challenge * challenge
Challenge message.
#define le16_to_cpu(value)
void * malloc(size_t size)
Allocate memory.
struct self_test ntlm_test __self_test
NTLM self-test.
#define KEY_TEST(name, DOMAIN, USERNAME, PASSWORD, EXPECTED)
Define a key generation digest test.
struct ntlm_data nt
NT response.
uint32_t flags
Negotiation flags.
struct ntlm_data user
User name.
struct ntlm_authenticate * expected
Expected Authenticate message.
static void ntlm_test_exec(void)
Perform NTLM self-test.
size_t ntlm_authenticate_len(struct ntlm_challenge_info *info, const char *domain, const char *username, const char *workstation)
Calculate NTLM Authenticate message length.
uint32_t offset
Offset from start of message header.
uint8_t data[48]
Additional event data.
void ntlm_key(const char *domain, const char *username, const char *password, struct ntlm_key *key)
Calculate NTLM verification key.
static void ntlm_key_okx(struct ntlm_key_test *test, const char *file, unsigned int line)
Report key generation test result.
NT LAN Manager (NTLM) authentication.
const char * password
Password (or NULL)
NTLM challenge information.
#define ntlm_key_ok(test)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
#define AUTHENTICATE_TEST(name, DOMAIN, USERNAME, PASSWORD, WORKSTATION, NONCE, CHALLENGE, EXPECTED)
Define an authentication test.
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
#define ntlm_authenticate_ok(test)