Totp

Time-based one-time password (TOTP) implementation according to rfc6238

Internal

should only be used by the TYPO3 Core

Table of Contents

Properties

$algo  : string
$epoch  : int
$length  : int
$secret  : string
$step  : int

Methods

__construct()  : mixed
generateEncodedSecret()  : string
Generate the shared secret (K) by using a random and applying additional authentication factors like username or email address.
generateTotp()  : string
Generate a time-based one-time password for the given counter according to rfc4226
getTotpAuthUrl()  : string
Generate and return the otpauth URL for TOTP
verifyTotp()  : bool
Verify the given time-based one-time password
compare()  : bool
Compare given time-based one-time password with a time-based one-time password generated from the known $counter (the moving factor).
getDecodedSecret()  : string
getTimeCounter()  : int
Generate the counter value (moving factor) from the given timestamp

Properties

Methods

__construct()

public __construct(string $secret[, string $algo = 'sha1' ][, int $length = 6 ][, int $step = 30 ][, int $epoch = 0 ]) : mixed
Parameters
$secret : string
$algo : string = 'sha1'
$length : int = 6
$step : int = 30
$epoch : int = 0

generateEncodedSecret()

Generate the shared secret (K) by using a random and applying additional authentication factors like username or email address.

public static generateEncodedSecret([array<string|int, mixed> $additionalAuthFactors = [] ]) : string
Parameters
$additionalAuthFactors : array<string|int, mixed> = []
Return values
string

generateTotp()

Generate a time-based one-time password for the given counter according to rfc4226

public generateTotp(int $counter) : string
Parameters
$counter : int

A timestamp (counter) according to rfc6238

Return values
string

The generated TOTP

getTotpAuthUrl()

Generate and return the otpauth URL for TOTP

public getTotpAuthUrl(string $issuer[, string $account = '' ][, array<string|int, mixed> $additionalParameters = [] ]) : string
Parameters
$issuer : string
$account : string = ''
$additionalParameters : array<string|int, mixed> = []
Return values
string

verifyTotp()

Verify the given time-based one-time password

public verifyTotp(string $totp[, int|null $gracePeriod = null ]) : bool
Parameters
$totp : string

The time-based one-time password to be verified

$gracePeriod : int|null = null

The grace period for the TOTP +- (mainly to circumvent transmission delays)

Return values
bool

compare()

Compare given time-based one-time password with a time-based one-time password generated from the known $counter (the moving factor).

protected compare(string $totp, int $counter) : bool
Parameters
$totp : string

The time-based one-time password to verify

$counter : int

The counter value, the moving factor

Return values
bool

getDecodedSecret()

protected getDecodedSecret() : string
Return values
string

getTimeCounter()

Generate the counter value (moving factor) from the given timestamp

protected getTimeCounter(int $timestamp) : int
Parameters
$timestamp : int
Return values
int

        
On this page

Search results