From WikiChip
$totp Identifier - mIRC
< mirc‎ | identifiers
Revision as of 20:14, 15 May 2018 by Maroonbells (talk | contribs) (Add'l details)

$totp returns a TOTP (Time-based One-time Password) based on the specified parameters.

See the Wikipedia page for TOTP for details.

Synopsis

$totp(key[, time[, hash[, digits[, timestep]]]]) </pre>

Parameters

  • key - the key is required and can be in a base16 format of either 40, 64 or 128 chars; or in a base32 format (created using $encode) of either 16, 24 or 32 chars; or a base32 econding string of any multiple of 8 greater than 8; or plain text; or it can also be in a Google Authenticator format ie lowercase with spaces.
  • time - optional, a time in second, default to $ctime ("in seconds" assumes that 'timestep' is also defined in seconds)
  • hash - optional, hashing algorithm, default to sha1 (Other possibles: md5, sha256, sha384, sha512 )
  • digits - optional, number of digits, default to 6 (Valid: 3 thru 9)
  • timestep - optional, number of timestep, default to 30
  • Note: "Optional" parameters are not allowed to be $null when defining later parameters.
  • Output number is the same for all "time" values where $int($calc(time / timestep)) is the same N value. An application allowing a "grace period" for recognizing tokens for multiple intervals must calculate result where time=time+timestep and time=time-timestep.
  • $totp is equivalent to $hotp(key , $int(time / timestep) , hash , digits ) (See $hotp for more syntax details - even though /help states that only 3 lengths of valid Base32 strings are decoded, but actually decodes all Base32 lengths of 16+ which are multiples of 8 without containing the '=' character.

Properties

None

Example

Password changing every hour on-the-hour (long intervals are NOT recommended)
//echo -a $totp(Secret case-sensitive Pass Key,$ctime,sha512,9,3600)
Because password is short, allowed-retries and length of interval should be short enough to deter brute-force attempts.
 
recognize password reply for the current 30-sec interval plus the prior or following intervals. Uses defaults sha1, 6 digits, and 30 sec interval:
var %t1 $ctime , %t2 = $ctime + 30 , %t3 = $ctime - 30
var %totp1 $totp(Secret Key,%t1) , %totp2 $totp(Secret Key,%t2) , %totp3 $totp(Secret Key,%t3)
if ($istok(%totp1 %totp2 %totp3,%reply,32)) goto Accepted
 
For internal use only because $ticks is different for everyone, password changes every 60 seconds, but not necessarily at :00 seconds.
$totp(Secret Key,$ticks,sha256,9,60000)
 
$totp is a specific usage of $hotp, using the number of timestep intervals as the counter.
//var %key password , %ctime $ctime , %timestep 30 , %digits 9 , %hash sha256 , %interval $int($calc($ctime / %timestep)) | echo -a interval %interval ctime %ctime $totp(%key,%ctime,%hash,%digits,%timestep) same as $hotp(%key,%interval,%hash,%digits)

Compatibility

Added: mIRC v7.42
Added on: 17 Jul 2015
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also