*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Copyright 2003 Alan DeKok <aland@freeradius.org>
+ * Copyright 2006 The FreeRADIUS server project
*/
/*
* The LEAP type (0x11) is *not* included in the type data...
*/
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+
#include <stdio.h>
#include <stdlib.h>
#include "eap.h"
*/
static int eapleap_ntpwdhash(unsigned char *ntpwdhash, VALUE_PAIR *password)
{
- if (password->attribute == PW_PASSWORD) {
- int i;
+ if ((password->attribute == PW_USER_PASSWORD) ||
+ (password->attribute == PW_CLEARTEXT_PASSWORD)) {
+ size_t i;
unsigned char unicode[512];
/*
* Yes, the *even* bytes have the values,
* and the *odd* bytes are zero.
*/
- unicode[(i << 1)] = password->strvalue[i];
+ unicode[(i << 1)] = password->vp_strvalue[i];
}
/*
* Get the NT Password hash.
*/
- md4_calc(ntpwdhash, unicode, password->length * 2);
+ fr_md4_calc(ntpwdhash, unicode, password->length * 2);
} else { /* MUST be NT-Password */
if (password->length == 32) {
- password->length = lrad_hex2bin(password->strvalue,
- password->strvalue,
+ password->length = fr_hex2bin(password->vp_strvalue,
+ password->vp_octets,
16);
}
if (password->length != 16) {
return 0;
}
- memcpy(ntpwdhash, password->strvalue, 16);
+ memcpy(ntpwdhash, password->vp_strvalue, 16);
}
return 1;
}
VALUE_PAIR *user_name, VALUE_PAIR* password,
leap_session_t *session, VALUE_PAIR **reply_vps)
{
- int i;
+ size_t i;
unsigned char ntpwdhash[16], ntpwdhashhash[16];
unsigned char buffer[256];
LEAP_PACKET *reply;
- char *p;
+ unsigned char *p;
VALUE_PAIR *vp;
/*
/*
* Copy the name over, and ensure it's NUL terminated.
*/
- memcpy(reply->name, user_name->strvalue, user_name->length);
+ memcpy(reply->name, user_name->vp_strvalue, user_name->length);
reply->name[user_name->length] = '\0';
reply->name_len = user_name->length;
eapleap_free(&reply);
return NULL;
}
- md4_calc(ntpwdhashhash, ntpwdhash, 16);
+ fr_md4_calc(ntpwdhashhash, ntpwdhash, 16);
/*
* Calculate our response, to authenticate ourselves
memcpy(p, session->peer_challenge, 8); /* PC */
p += 8;
memcpy(p, session->peer_response, 24); /* PR */
- p += 24;
/*
* These 16 bytes are the session key to use.
*/
- librad_md5_calc(ntpwdhash, buffer, 16 + 8 + 24 + 8 + 24);
+ fr_md5_calc(ntpwdhash, buffer, 16 + 8 + 24 + 8 + 24);
- memcpy(vp->strvalue + vp->length, ntpwdhash, 16);
- memset(vp->strvalue + vp->length + 16, 0,
- sizeof(vp->strvalue) - (vp->length + 16));
+ memcpy(vp->vp_strvalue + vp->length, ntpwdhash, 16);
+ memset(vp->vp_strvalue + vp->length + 16, 0,
+ sizeof(vp->vp_strvalue) - (vp->length + 16));
i = 16;
- rad_tunnel_pwencode(vp->strvalue + vp->length, &i,
- request->secret, request->packet->vector);
+ rad_tunnel_pwencode(vp->vp_strvalue + vp->length, &i,
+ request->client->secret, request->packet->vector);
vp->length += i;
pairadd(reply_vps, vp);
* Fill the challenge with random bytes.
*/
for (i = 0; i < reply->count; i++) {
- reply->challenge[i] = lrad_rand();
+ reply->challenge[i] = fr_rand();
}
DEBUG2(" rlm_eap_leap: Issuing AP Challenge");
/*
* Copy the name over, and ensure it's NUL terminated.
*/
- memcpy(reply->name, user_name->strvalue, user_name->length);
+ memcpy(reply->name, user_name->vp_strvalue, user_name->length);
reply->name[user_name->length] = '\0';
reply->name_len = user_name->length;