Slide 28
Slide 28 text
Chris Stone | E-Moxie | @cmstone | php[tek] 2014 | Two Factor Authentication and You | https://joind.in/10645
https://github.com/cmstone/phptek2014-‐two-‐factor/
28
WORKFLOW
$currentPassword
=
TwoFactor::getSecret($secretKey,
$timestamp);
———————
public
static
function
getSecret($key,
$counter)
{
if
(strlen($key)
<
8)
{
throw
new
Exception('Secret
key
is
too
short.
Must
be
at
least
16
base
32
characters');
}
!
$bin_counter
=
pack('N*',
0)
.
pack('N*',
$counter);
//
Counter
must
be
64-‐bit
int
$hash
=
hash_hmac('sha1',
$bin_counter,
$key,
true);
!
return
str_pad(self::oathTruncate($hash),
self::otpLength,
'0',
STR_PAD_LEFT);
}
!
//
$currentPassword
=
373604
Step 4 - Decode