diff options
author | Calvin Morrison <calvin@fastmailteam.com> | 2018-10-16 12:50:28 -0400 |
---|---|---|
committer | Calvin Morrison <calvin@fastmailteam.com> | 2018-10-16 12:50:28 -0400 |
commit | b0a8b2b4f74b03272c64af66257c3503331674a9 (patch) | |
tree | e301d7d2db8fad6b071537e1bd6f205ecc226e39 /totp.pl | |
parent | 2aa85f379bd8e18112bc27587022a0a2b79cbafb (diff) |
Diffstat (limited to 'totp.pl')
-rw-r--r-- | totp.pl | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -16,14 +16,14 @@ sub hotp_truncate { my $offset = (hex $lastbyte) & 0xf; my $offset = $offset * 2; - my $truncate = ( + my $truncate = ( (hex substr($hex, $offset , 2) & 0x7f) << 24 | (hex substr($hex, $offset + 2, 2) & 0xff) << 16 | (hex substr($hex, $offset + 4, 2) & 0xff) << 8 | (hex substr($hex, $offset + 6, 2) & 0xff) ); - # 6 letter; + # 6 letter; $truncate = substr($truncate, -6); return $truncate; @@ -49,14 +49,13 @@ sub hotp { my $secret_hex = unpack "H*", decode_base32($secret); my $time_hex= sprintf("%016s", sprintf("%x", $time)); - # SHA-1 Hex your secret my $hash = hmac_sha1_hex_string($time_hex, $secret_hex); + # run trunc to generate a user useable number my $otp = hotp_truncate($hash); return $otp; - } my $secret = ""; |