Table of contents
Source: shared/code/tce_functions_otp.php
Functions for One Time Password (OTP).
Functions
F_checkOTPLogin()
Check a One Time Password submitted at login.
A valid code is stored in the sessions table for 5 minutes and is rejected while stored.
function F_checkOTPLogin(mixed $user_name, mixed $otpkey, mixed $code): bool
Parameters:
$user_name(mixed): (string) user name.$otpkey(mixed): (string) user’s One Time Password secret key (Base32 encoded).$code(mixed): (string) submitted code.
Returns: bool: true if the code is valid and not yet used, false otherwise.
Source: shared/code/tce_functions_otp.php:164
F_decodeBase32()
Decode a Base32 encoded string.
function F_decodeBase32(mixed $code): Decoded
Parameters:
$code(mixed): (string) Base32 code to be decoded.
Returns: Decoded: key.
Source: shared/code/tce_functions_otp.php:66
F_getOTP()
Get a One Time Password for the specified secret key.
function F_getOTP(mixed $otpkey, mixed $mtime = 0): OTP
Parameters:
$otpkey(mixed): (string) One Time Password secret key.$mtime(mixed): (int) Reference time in microseconds.
Returns: OTP
Source: shared/code/tce_functions_otp.php:96
F_getRandomOTPkey()
Return a random One Time Password Secret Key (Base32 encoded).
function F_getRandomOTPkey(): Base32
Returns: Base32: encoded key.
Source: shared/code/tce_functions_otp.php:48
F_isValidOTPCode()
Check a One Time Password code against a secret key.
The code must have 6 digits and match the key for the current, previous or next 30-second step.
function F_isValidOTPCode(mixed $otpkey, mixed $code, mixed $mtime = 0.0): bool
Parameters:
$otpkey(mixed): (string) One Time Password secret key (Base32 encoded).$code(mixed): (string) code to check.$mtime(mixed): (float) reference time in seconds (0 = current time).
Returns: bool: true if the code matches, false otherwise.
Source: shared/code/tce_functions_otp.php:131
F_isValidOTPkey()
Check whether a normalized One Time Password Secret Key is a Base32 string of 16 to 255 characters.
function F_isValidOTPkey(string $key): bool
Parameters:
$key(string): normalized key
Returns: bool: true if the key is valid
Source: shared/code/tce_functions_otp.php:39
F_normalizeOTPkey()
Normalize a One Time Password Secret Key (Base32 encoded) entered by a user.
White space and ‘=’ padding are removed and letters are converted to uppercase.
function F_normalizeOTPkey(string $key): string
Parameters:
$key(string): key to normalize
Returns: string: normalized key