I'm trying to add HMAC verification in to the simple perl client. While I think i have it right, I can't seem to generate a response that matches the h= part from the Yubico servers.
I've taken the sample code, and added a few bits:
Code:
use Digest::SHA qw(hmac_sha1);
use MIME::Base64;
my $MyYubicoAPIKey = "myAPIkey";
.
. snip
.
my $YubicoAuthString = "&id=". $ARGV[0] . "&otp=" . $ARGV[1];
my $YubicoAuthSrvURL = YubicoAuthSrvURLprefix . $YubicoAuthString;
my $mech = WWW::Mechanize->new();
$mech->get($YubicoAuthSrvURL);
my $YubicoAuthSrvResponse = $mech->response()->content();
if ($YubicoAuthSrvResponse =~ /status=OK/) {
print "\nOTP verification ok\n";
print "$YubicoAuthSrvResponse";
print "v=" . encode_base64(hmac_sha1($YubicoAuthString, $MyYubicoAPIKey));
} else {
print "\nOTP verification failed\n";
print "$YubicoAuthSrvResponse";
print "v=" . encode_base64(hmac_sha1($YubicoAuthString, $MyYubicoAPIKey));
}
when i run it, it doesn't generate the proper verification (v=):
(mID is my numeric ID from Yubico when i generated an API key)
Code:
perl YubicoAuthClient.pl myID fghbibnivrtkrvdetdhcrfrklgcrkrkrvrchiriitdkt
OTP verification ok
h=di+/stO00nh4oDaqA+7sJ24TI0Y=
t=2008-07-09T02:33:19Z0762
status=OK
v=JsUPm4RnBwwOIDodGYEf2MDYFFI=
i guess my question is, am i passing the right info to the hash and base64 functions? am i missing something here?