47 RCSID(
"$Id: d81df779658b5ba773c3b8dbb49abddcc227aad0 $")
54 #include <freeradius-devel/md5.h>
69 if (!eap_round || !eap_round->
response ||
91 if (data->
count != 24) {
92 REDEBUG(
"Bad NTChallengeResponse in LEAP stage 3");
98 if (data->
count != 8) {
99 REDEBUG(
"Bad AP Challenge in LEAP stage 5");
110 if (!packet)
return NULL;
145 packet->
name = talloc_array(packet,
char, name_len + 1);
151 packet->
name[name_len] =
'\0';
163 if ((password->
da->
attr == PW_USER_PASSWORD) ||
164 (password->
da->
attr == PW_CLEARTEXT_PASSWORD)) {
166 uint8_t ucs2_password[512];
171 len =
fr_utf8_to_ucs2(ucs2_password,
sizeof(ucs2_password), password->vp_strvalue, password->vp_length);
173 REDEBUG(
"Error converting password to UCS2");
184 if (password->vp_length == 32) {
185 p = talloc_array(password, uint8_t, 16);
186 password->vp_length =
fr_hex2bin(p, 16, password->vp_strvalue, password->vp_length);
188 if (password->vp_length != 16) {
198 memcpy(out, password->vp_octets, 16);
210 uint8_t response[24];
215 if ((!password) || (!session)) {
227 if (memcmp(response, packet->
challenge, 24) == 0) {
228 RDEBUG2(
"NTChallengeResponse from AP is valid");
232 REDEBUG(
"FAILED incorrect NtChallengeResponse from AP");
244 uint8_t
hash[16], mppe[16];
245 uint8_t *p, buffer[256];
253 if ((!password) || (!session)) {
258 if (!reply)
return NULL;
273 reply->
name = talloc_array(reply,
char, user_name->vp_length + 1);
282 memcpy(reply->
name, user_name->vp_strvalue, user_name->vp_length);
283 reply->
name[user_name->vp_length] =
'\0';
284 reply->
name_len = user_name->vp_length;
305 REDEBUG(
"Failed to create Cisco-AVPair attribute. LEAP cancelled");
330 strcpy(q,
"leap:session-key=");
332 memcpy(q + 17, hash, 16);
337 vp->vp_length = 17 + i;
369 for (i = 0; i < reply->
count; i++) {
372 RDEBUG2(
"Issuing AP Challenge");
377 reply->
name = talloc_array(reply,
char, user_name->vp_length + 1);
386 memcpy(reply->
name, user_name->vp_strvalue, user_name->vp_length);
387 reply->
name[user_name->vp_length] =
'\0';
388 reply->
name_len = user_name->vp_length;
406 switch (reply->
code) {
438 REDEBUG(
"Internal sanity check failed");
void fr_md5_calc(uint8_t *out, uint8_t const *in, size_t inlen)
Calculate the MD5 hash of the contents of a buffer.
uint32_t fr_rand(void)
Return a 32-bit random number.
char const * secret
Secret PSK.
static int eap_leap_ntpwdhash(uint8_t *out, REQUEST *request, VALUE_PAIR *password)
void fr_md4_calc(uint8_t out[MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Calculate the MD4 hash of the contents of a buffer.
eap_packet_t * request
Packet we will send to the peer.
leap_packet_t * eap_leap_initiate(REQUEST *request, eap_round_t *eap_round, VALUE_PAIR *user_name)
static unsigned int hash(char const *username, unsigned int tablesize)
void fr_pair_value_strsteal(VALUE_PAIR *vp, char const *src)
Reparent an allocated char buffer to a VALUE_PAIR.
unsigned char * challenge
size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen)
Convert hex strings to binary data.
unsigned int attr
Attribute number.
uint8_t peer_response[24]
Stores an attribute, a value and various bits of other data.
Contains a pair of request and response packets.
uint8_t vector[AUTH_VECTOR_LEN]
RADIUS authentication vector.
ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen)
Convert UTF8 string to UCS2 encoding.
int eap_leap_stage4(REQUEST *request, leap_packet_t *packet, VALUE_PAIR *password, leap_session_t *session)
#define FR_TUNNEL_PW_ENC_LENGTH(_x)
#define pair_make_reply(_a, _b, _c)
void eap_leap_mschap(unsigned char const *win_password, unsigned char const *challenge, unsigned char *response)
int eap_leap_compose(REQUEST *request, eap_round_t *eap_round, leap_packet_t *reply)
RADIUS_PACKET * packet
Incoming request.
uint8_t peer_challenge[8]
leap_packet_t * eap_leap_stage6(REQUEST *request, leap_packet_t *packet, VALUE_PAIR *user_name, VALUE_PAIR *password, leap_session_t *session)
fr_dict_attr_t const * da
Dictionary attribute defines the attribute.
eap_packet_t * response
Packet we received from the peer.
RADCLIENT * client
The client that originally sent us the request.
int fr_radius_encode_tunnel_password(char *encpw, size_t *len, char const *secret, uint8_t const *vector)
Encode Tunnel-Password attributes when sending them out on the wire.
leap_packet_t * eap_leap_extract(REQUEST *request, eap_round_t *eap_round)
void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t len)
Copy data into an "octets" data type.