Class Oath
Oath implementation of the OATH specification for both HOTP and TOTP one time
passwords (RFC4226 and its extension HOTPTimeBased Internet-Draft,
respectively).
See http://www.openauthentication.org
Methods summary
public
|
#
__construct( string $secret = null, string $crypto = 'sha1' )
Construct a new OATH object using the given secret and HMAC hash function
Construct a new OATH object using the given secret and HMAC hash function
Parameters
- $secret
- The shared secret
- $crypto
- The crypto system to use during the HMAC calculation
|
public
|
#
setSecret( string $secret )
Set the secret key to use along with the HMAC calculation
Set the secret key to use along with the HMAC calculation
Parameters
- $secret
- The shared secret
|
public
|
#
setCrypto( string $crypto )
Set the algorithm to use during the HMAC calculation
Set the algorithm to use during the HMAC calculation
Parameters
- $crypto
- The crypto system to use during the HMAC calculation
|
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)
Checks whether the given one time password is a valid HOTP password
using the given counter and VLAV (Validation Look Ahead Value)
Parameters
- $otp
- The one time password to validate
- $counter
- The counter value
- $vlav
- The validation look ahead value
Returns
boolean True if this OTP is valid, false otherwise
|
public
boolean
|
#
checkTotp( string $otp, integer $time )
Checks whether the given one time password is a valid TOTP password using the given time
Checks whether the given one time password is a valid TOTP password using the given time
Parameters
- $otp
- The one time password to validate
- $time
- The time value
Returns
boolean True if this OTP is valid, false otherwise
|
public static
string
|
#
hotp( string $key, integer $counter, $digit_length = 6, $crypto = 'sha1' )
Generate an HOTP pass phrase
Generate an HOTP pass phrase
Parameters
- $key
- The secret key
- $counter
- The counter value
- $digit_length
- length of the resulting pass phrase
- $crypto
- algorithm to use in the HMAC calculation
Returns
string The HOTP pass pharse
|
public static
string
|
#
totp( string $key, integer $counter, $digit_length = 6, $crypto = 'sha1' )
Generate an TOTP pass phrase
Generate an TOTP pass phrase
Parameters
- $key
- The secret key
- $counter
- The counter value (e.g. Unix time)
- $digit_length
- length of the resulting pass phrase
- $crypto
- algorithm to use in the HMAC calculation
Returns
string The TOTP pass pharse
|