i m trying to authenticate with rlm_perl using chap with following perl script but doesn't seem to work. i m guessing chap-password should be in hex (0x) format but doesn't seem to be in. hope some one can help me out
my $want_password="123";
my $given_password;
my $given_chap_challenge;
$given_password=$RAD_REQUEST{'CHAP-Password'};
$given_chap_challenge=$RAD_REQUEST{'CHAP-Challenge'};
$given_password =~ s/^0x//;
$given_chap_challenge =~ s/^0x//;
my $chap_password = pack("H*", $given_password);
my $chap_challenge = pack("H*", $given_chap_challenge);
my $md5 = new Digest::MD5;
$md5->reset;
$md5->add(substr($chap_password, 0, 1));
$md5->add($want_password);
$md5->add($chap_challenge);
my $digest = $md5->digest();
my $subby = substr($chap_password,1);
my $subby2 = substr($chap_password,0,1);
if ($digest ne substr($chap_password, 1)) {
#return 0; #Bad pass returning 0
$RAD_REPLY{'Reply-Message'} = "Denied access for invalid password";