57 #define DATA(...) { __VA_ARGS__ } 60 #define MSCHAPV2_TEST( name, USERNAME, PASSWORD, CHALLENGE, PEER, \ 62 static const struct mschapv2_challenge name ## _challenge = { \ 65 static const struct mschapv2_challenge name ## _peer = { \ 68 static const union { \ 69 struct mschapv2_response response; \ 70 uint8_t byte[ sizeof ( struct mschapv2_response ) ]; \ 71 } name ## _response = { \ 74 static const union { \ 75 struct mschapv2_auth auth; \ 76 uint8_t byte[ sizeof ( struct mschapv2_auth ) ]; \ 80 static struct mschapv2_test name = { \ 81 .username = USERNAME, \ 82 .password = PASSWORD, \ 83 .challenge = &name ## _challenge, \ 84 .peer = &name ## _peer, \ 85 .response = &name ## _response.response, \ 86 .auth = &name ## _auth.auth, \ 92 DATA ( 0x5b, 0x5d, 0x7c, 0x7d, 0x7b, 0x3f, 0x2f, 0x3e,
93 0x3c, 0x2c, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28 ),
94 DATA ( 0x21, 0x40, 0x23, 0x24, 0x25, 0x5e, 0x26, 0x2a,
95 0x28, 0x29, 0x5f, 0x2b, 0x3a, 0x33, 0x7c, 0x7e ),
96 DATA ( 0x21, 0x40, 0x23, 0x24, 0x25, 0x5e, 0x26, 0x2a,
97 0x28, 0x29, 0x5f, 0x2b, 0x3a, 0x33, 0x7c, 0x7e,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 0x82, 0x30, 0x9e, 0xcd, 0x8d, 0x70, 0x8b, 0x5e,
100 0xa0, 0x8f, 0xaa, 0x39, 0x81, 0xcd, 0x83, 0x54,
101 0x42, 0x33, 0x11, 0x4a, 0x3d, 0x85, 0xd6, 0xdf,
103 "S=407A5589115FD0D6209F510FE9C04566932CDA56" );
113 const char *file,
unsigned int line ) {
119 test->peer, &response );
120 okx (
memcmp ( &response,
test->response, sizeof ( response ) ) == 0,
125 test->response, &auth );
126 okx (
memcmp ( &auth,
test->auth, sizeof ( auth ) ) == 0, file, line );
128 #define mschapv2_ok( test ) \ 129 mschapv2_okx ( test, __FILE__, __LINE__ ) static void mschapv2_okx(struct mschapv2_test *test, const char *file, unsigned int line)
Report an MS-CHAPv2 test result.
const char * password
Password.
#define MSCHAPV2_TEST(name, USERNAME, PASSWORD, CHALLENGE, PEER, RESPONSE, AUTH)
Define an MS-CHAPv2 test.
#define DATA(...)
Define inline data.
Self-test infrastructure.
const char * name
Test set name.
void mschapv2_response(const char *username, const char *password, const struct mschapv2_challenge *challenge, const struct mschapv2_challenge *peer, struct mschapv2_response *response)
Calculate MS-CHAPv2 challenge response.
const struct mschapv2_auth * auth
Expected authenticator response.
#define okx(success, file, line)
Report test result.
MS-CHAPv2 authentication.
struct self_test mschapv2_test __self_test
MS-CHAPv2 self-test.
const char * username
Username.
void mschapv2_auth(const char *username, const char *password, const struct mschapv2_challenge *challenge, const struct mschapv2_response *response, struct mschapv2_auth *auth)
Calculate MS-CHAPv2 authenticator response.
const struct mschapv2_response * response
Expected challenge response.
An MS-CHAPv2 challenge response.
static void mschapv2_test_exec(void)
Perform MS-CHAPv2 self-test.
An MS-CHAPv2 authenticator response.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const struct mschapv2_challenge * peer
Peer challenge.
#define mschapv2_ok(test)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
const struct mschapv2_challenge * challenge
Authenticator challenge.