Joomla CMS  3.10.11 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.10.11 et du framework Joomla Platform intégré
Référence de la classe FOFEncryptTotp

Fonctions membres publiques

 __construct ($timeStep=30, $passCodeLength=6, $secretLength=10, $base32=null)
 
 getPeriod ($time=null)
 
 checkCode ($secret, $code)
 
 getCode ($secret, $time=null)
 
 getUrl ($user, $hostname, $secret)
 
 generateSecret ()
 

Fonctions membres protégées

 hashToInt ($bytes, $start)
 

Attributs privés

 $_passCodeLength = 6
 
 $_pinModulo
 
 $_secretLength = 20
 
 $_timeStep = 30
 
 $_base32 = null
 

Documentation des constructeurs et destructeur

◆ __construct()

__construct (   $timeStep = 30,
  $passCodeLength = 6,
  $secretLength = 10,
  $base32 = null 
)

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.

Paramètres
int$timeStepThe Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
int$passCodeLengthThe generated passcode length. Default: 6 digits.
int$secretLengthThe length of the secret key. Default: 10 bytes (80 bits).
Object$base32The base32 en/decrypter

Documentation des fonctions membres

◆ checkCode()

checkCode (   $secret,
  $code 
)

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

Paramètres
string$secretThe Base32-encoded secret key
string$codeThe passcode to check
Renvoie
boolean True if the code is valid

Références $i.

◆ generateSecret()

generateSecret ( )

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

Renvoie
string
Note
Since 3.9.25 we use the secure method "random_bytes" over the original insecure "rand" function. The random_bytes function has been backported to outdated PHP versions by the core shipped library paragonie/random_compat

Références FOFEncryptBase32\encode().

◆ getCode()

getCode (   $secret,
  $time = null 
)

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

Paramètres
string$secretThe Base32-encoded secret key
int$timeUNIX timestamp
Renvoie
string

Références $hash, et $offset.

◆ getPeriod()

getPeriod (   $time = null)

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.

Paramètres
int | null$timeTimestamp
Renvoie
int The time period since the UNIX Epoch

◆ getUrl()

getUrl (   $user,
  $hostname,
  $secret 
)

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

Paramètres
string$userUser
string$hostnameHostname
string$secretSecret string
Renvoie
string

Références $url, et $user.

◆ hashToInt()

hashToInt (   $bytes,
  $start 
)
protected

Extracts a part of a hash as an integer

Paramètres
string$bytesThe hash
string$startThe char to start from (0 = first char)
Renvoie
string

Références $input, et $start.

Documentation des champs

◆ $_base32

$_base32 = null
private

◆ $_passCodeLength

$_passCodeLength = 6
private

◆ $_pinModulo

$_pinModulo
private

◆ $_secretLength

$_secretLength = 20
private

◆ $_timeStep

$_timeStep = 30
private

La documentation de cette classe a été générée à partir du fichier suivant :