Class FOFEncryptTotp

Description

This class provides an RFC6238-compliant Time-based One Time Passwords, compatible with Google Authenticator (with PassCodeLength = 6 and TimePeriod = 30).

  • since: 1.0

Located in /libraries/fof/encrypt/totp.php (line 17)


	
			
Method Summary
 FOFEncryptTotp __construct ([int $timeStep = 30], [int $passCodeLength = 6], [int $secretLength = 10])
 boolean checkCode (string $secret, string $code)
 string generateSecret ()
 string getCode (string $secret, [int $time = null])
 int getPeriod ([int|null $time = null])
 string getUrl (string $user, string $hostname, string $secret)
 string hashToInt (string $bytes, string $start)
Methods
Constructor __construct (line 37)

Initialises an RFC6238-compatible TOTP generator. Please note that this class does not implement the constraint in the last paragraph of ยง5.2 of RFC6238. It's up to you to ensure that the same user/device does not retry validation within the same Time Step.

  • access: public
FOFEncryptTotp __construct ([int $timeStep = 30], [int $passCodeLength = 6], [int $secretLength = 10])
  • int $timeStep: The Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
  • int $passCodeLength: The generated passcode length. Default: 6 digits.
  • int $secretLength: The length of the secret key. Default: 10 bytes (80 bits).
checkCode (line 75)

Check is the given passcode $code is a valid TOTP generated using secret key $secret

  • return: True if the code is valid
  • access: public
boolean checkCode (string $secret, string $code)
  • string $secret: The Base32-encoded secret key
  • string $code: The passcode to check
generateSecret (line 157)

Generates a (semi-)random Secret Key for TOTP generation

  • access: public
string generateSecret ()
getCode (line 99)

Gets the TOTP passcode for a given secret key $secret and a given UNIX timestamp $time

  • access: public
string getCode (string $secret, [int $time = null])
  • string $secret: The Base32-encoded secret key
  • int $time: UNIX timestamp
getPeriod (line 54)

Get the time period based on the $time timestamp and the Time Step defined. If $time is skipped or set to null the current timestamp will be used.

  • return: The time period since the UNIX Epoch
  • access: public
int getPeriod ([int|null $time = null])
  • int|null $time: Timestamp
getUrl (line 143)

Returns a QR code URL for easy setup of TOTP apps like Google Authenticator

  • access: public
string getUrl (string $user, string $hostname, string $secret)
  • string $user: User
  • string $hostname: Hostname
  • string $secret: Secret string
hashToInt (line 126)

Extracts a part of a hash as an integer

  • access: protected
string hashToInt (string $bytes, string $start)
  • string $bytes: The hash
  • string $start: The char to start from (0 = first char)

Documentation generated on Tue, 19 Nov 2013 15:15:56 +0100 by phpDocumentor 1.4.3