Subject: | Will not verify with Google Authenticator |
I have built Authen::OATH under perl-5.10.1 (perlbrew). I am attempting
to verify TOTP using Google Authenticator, but the hashes are not
matching. I tried a tight loop that checked 100K timeblocks (30 second
chunks) above and 100K timeblocks below the current time, no hashes
matched in either case. My clocks are sync'd using ntp so I'm positive
the accuracy is within a few hundreths of a second.
The attached script uses the Auth Info represented by the test QRCode
generated here:
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/todd@tlyons%3Fsecret%3DIWYIR3ES2MMGNSIO
The above belongs to a box that is just a test account, it is not used
for actual authentication.
Am I doing something wrong? Does the Google Authenticator use some
enhancement of the spec that Authen::OATH does not support?
Linux tlyons 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:40:58 UTC
2011 i686 GNU/Linux
[todd@tlyons ~/projects/google-authenticator/perl]$ perl check_auth.pl
413196
Passed token 413196
Calculated TOTP 735136
Right now I'm comparing what the OATH.pm does compared to the
google-authenticator pam module, but do not see anything that indicates
to me what I am doing wrong.
Subject: | check_auth.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Authen::OATH;
my $token = shift() || usage();
sub usage {
my $prog = `basename $0`;
chomp $prog;
print <<EOF;
Usage: $prog token
EOF
exit 0;
}
# This will be a database lookup to obtain the key once past testing
my $key = 'IWYIR3ES2MMGNSIO';
#my $oath = Authen::OATH->new( digest => "Digest::HMAC_SHA1" );
my $oath = Authen::OATH->new( );
my $totp = $oath->totp( $key );
print <<EOF;
Passed token $token
Calculated TOTP $totp
EOF