Class Oath
Oath implementation of the OATH specification for both HOTP and TOTP one time passwords (RFC4226 and its extension HOTPTimeBased Internet-Draft, respectively).
Methods summary
public
|
#
__construct( string $secret = null, string $crypto = "sha1" )
Construct a new OATH object using the given secret and HMAC hash function |
public
|
|
public
|
|
public
boolean
|
#
checkHotp( string $otp, integer $counter, integer $vlav = 0 )
Checks whether the given one time password is a valid HOTP password using the given counter and VLAV (Validation Look Ahead Value) |
public
boolean
|
#
checkTotp( string $otp, integer $time )
Checks whether the given one time password is a valid TOTP password using the given time |
public static
string
|
#
hotp( string $key, integer $counter, mixed $digit_length = 6, mixed $crypto = "sha1" )
Generate an HOTP pass phrase |
public static
string
|
#
totp( string $key, integer $counter, mixed $digit_length = 6, mixed $crypto = "sha1" )
Generate an TOTP pass phrase |
private static
|
#
hex2Bin( string $string )
Detects if the given string is in hex format, if not, converts it to hex |
private static
string
|
|
private static
string
|
#
truncate( string $hash, integer $digit_length = 6 )
Truncates the given hash per the RFC4226 truncation method |
Magic methods summary
Properties summary
private static
array
|
$digits_power |
#
Precomputed power values |
private
string
|
$secret |
#
Shared secret |
private
integer
|
$length |
#
Length of one time password |
private
integer
|
$moving_factor |
#
Moving factor of TOTP |
private
integer
|
$drift |
#
The number of seconds of drift to account for (+/- 3 minutes) |
private
string
|
$crypto |
#
The hash function to use during the HMAC calculation |